Skip to content
CCPEDIAby Unity Nodes
App Development

Designating any party in a list of parties as Controller

4 posts615 views11 likesLast activity Sep 2020

  1. ManishGroverOP 2

    Hi,

    I have a template with a list of parties. How can I allow any one of those parties to be able to exercise a choice, and pass that party to the resulting contract?

    Example below:

    template MyTemplate
      with 
        operator: Party 
        contacts : [Party]
        name: Text
      where 
        signatory operator 
        observer contacts 
    
        controller any one of the contacts can
          DoSomething: ContractId SomeProposal 
            with 
              newName : Text
            do 
              create SomeProposal with name = newName, operator, (contact who exercised the choice) 
    
    template SomeProposal
      with 
        operator: Party 
        name: Text 
        contact : Party 
      where 
        signatory contact 
    

    If there is another way to accomplish these things instead, that’s welcome too.

    Thanks!

  2. matt 6

    Can you do something like this using the dynamic choice construct?

       choice DoSomething : ContractId SomeProposal
         with
           contact : Party
           newName : Text
         controller contact
            do
              assertMsg "is not a contact" $ contact `elem` contacts
              create SomeProposal with name = newName, operator, contact
              
    
  3. cocreature 2

    Great answer @matt!

  4. ManishGrover 1

    Thank you Matt! This should work for me.