Hello Damlers,
I wan’t to parse a ContractId value that I get from self to a Text field. Is this possible?
data Example = Example with
reference: Text
…
create Example with reference = self
Hello Damlers,
I wan’t to parse a ContractId value that I get from self to a Text field. Is this possible?
data Example = Example with
reference: Text
…
create Example with reference = self
You cannot convert between contract ids & Text in Daml. If you need such a conversion, you could do it on the client side, where you have some automation that reads the contract id and then inputs it as a Text somewhere else. That said, I’d say that’s usually an antipattern and you should treat contract ids as opaque values.
If the use-case is storing contract ids of multiple types, you can wrap the contract ids in a type:
data WrappedId = FooId (ContractId Foo) | BarId (ContractId Bar)
Of course this requires knowing what templates you want to track up front.