"Ambiguous occurrence" error and Ability to archive a previous version of the Contract
Mod note: As of SDK 1.5.0 Scenarios have been superseded by the more powerful Daml Script. We now recommend using that for all purposes. For more information, and to learn how to use Script please check out @Andreas’ post on our blog.
I am experimenting with DAML
In this situation, I have a previous version of the CitizenRole Contract
By exercising the UpdateCitizenRegistration Choice, I would like to replace (or achive) the previous version of the Contract with the new one ?
1. template CitizenRole
2. with
3. operator : Party
4. citizen: Party
5. citizendetails : CitizenDetails
6. where
7. signatory citizen
8. key (citizen, citizendetails) : AccountKey
9. maintainer key._1
10. controller citizen can
11. UpdateCitizenRegistration : ContractId CitizenRole
12. with
13. newcitizendetails : CitizenDetails
14. do
15. // archive old... //
16. create this with
17. citizen = citizen
18. operator = operator
19. citizendetails = newcitizendetails
My current code (scenario) creates a second contract but does not archive the first (Line 15)
Here is my scenario code
setup = scenario do
operator <- getParty "Operator"
atriumhealth <- getParty "AtriumHealth"
alice <- getParty "Alice"
...
let citizendetails = CitizenDetails with idtype = "text" ; ssn = ""; did = "decentralized did"; firstname = "John" ; lastname = "Doe"; email = "john.doe@email.com" ; accept_vcoremail = "vc"; hippa_accept = True;insurance_id = "12345"
submit alice do
create CitizenRole with citizen = alice ; operator = operator ; citizendetails = citizendetails
let newcitizendetails = CitizenDetails with idtype = "text2" ; ssn = ""; did = "decentralized did"; firstname = "John" ; lastname = "Doe"; email = "john.doe@email.com" ; accept_vcoremail = "vc"; hippa_accept = True;insurance_id = "12345"
submit alice do
exercise UpdateCitizenRegistration with operator = operator ; citizen = alice; citizendetails = newcitizendetails
This last exercise also currently triggers an “Ambiguous occurrence” compile error
When you exercise, you exercise the choice on a contract. Which contract are you exercising this choice on?
You need to save the contract ID from your creation of a CitizenRole and pass it in as the first argument to exercise. You can do this with varName <-, just as you save the results of your getParty calls at the top of the scenario.