The first feature example is not working correctly
- Nguyen_Manh_CuongOP
I’ve followed the instruction in the given Getting Started page
The Message template yield an error when I’m creating the nonconsuming choice
What should I do to overcome the issue?
- cocreature 4
Hi @Nguyen_Manh_Cuong and welcome to the Daml forum!
The issue here is that you added the choice to the
Messagetemplate while it should have been added to theUsertemplate. The final result should look something like this:-- MAIN_TEMPLATE_BEGIN template User with username: Party following: [Party] where signatory username observer following -- MAIN_TEMPLATE_END key username: Party maintainer key -- FOLLOW_BEGIN nonconsuming choice Follow: ContractId User with userToFollow: Party controller username do assertMsg "You cannot follow yourself" (userToFollow /= username) assertMsg "You cannot follow the same user twice" (notElem userToFollow following) archive self create this with following = userToFollow :: following -- FOLLOW_END nonconsuming choice SendMessage: ContractId Message with sender: Party content: Text controller sender do assertMsg "Designated user must follow you back to send a message" (elem sender following) create Message with sender, receiver = username, content template Message with sender: Party receiver: Party content: Text where signatory sender, receiver - lordwilliam
@cocreature Thanks for your answer, I was making the same mistake and your answer solved it for me
