Choice : Archive current contract
- prajwalhegde3OP
Hi Everyone,
I have been trying to create a choice where “signatory” party/s can exercise a choice on a specific contract to archive it.
choice Archive_Contract : () controller signatory do exercise [...] ArchiveI guess, I have to pass the current contractId instead of […]. Not sure if this is the right approach but I tried passing it as “this.ContractId” , but seems like its giving me a error.
Can anyone help me with the correct syntax.
Thank you!
- rikotacards 2
A contract is archived by default once a choice is exercised. Assuming you don’t have the
nonconsumingkeyword in front of the choice, you don’t need to perform anything. You can justreturn (),more about nonconsuming here
https://docs.daml.com/daml/reference/choices.html#non-consuming-choices - prajwalhegde3 1
Thank you @rikotacards
- cocreature 2
Once you’ve changed it to a non-consuming choice, you can use self to get access to the contract id of the current contract.
- prajwalhegde3
Thank you @cocreature
I do have one more question though…
As per the DAML documentation Archive choice is implicitly added to every template.
Currently I have a Java GRPC method to invoke other choices defined in the template using the “CommandServiceGrpc” stub, so wanted to know if we can invoke this Archive choice from the same as well.
Ref:
https://docs.daml.com/daml/intro/4_Transformations.html#the-archive-choiceThank you!!
- cocreature 2
The choice is implicitly added by the compiler. So in Daml-LF it always exists and it’s available over the ledger API. The Java codegen should generate it for you like any other choice. If you don’t use the codegen, just call the choice called
Archive.