Skip to content
CCPEDIAby Unity Nodes
App Development

forA with a list and additional parameter

2 posts214 views2 likesLast activity Jun 2022

  1. Ashok_RajOP 1

    In trigger, I am using forA to run a function over a list. Addiitional i want to pass the party which is running the trigger as a parameter to the same function. How do i do that.

    here is the flow

    list <- Query and filter contracts
    apply function Func1 on the each contract on the list
    Inside Func1, I am exercising a choice, where i need to specify who is the party that's exercising the choice
    
    

    i tried

    forA listContracts function1 party
    
    function1 : ContractTemplate -> Party->TriggerA () ()
    function1 contracts party = do
    

    If there is no option, is there a way to pull the current party thats running the trigger with a function

  2. cocreature 1

    You can do something like this

    rule party = do
      …
      forA … (\c -> function1 c party)
    

    It’s common to swap the arguments to such functions if you often use them this way, then you can do something like this:

    function1 : Party -> ContractTemplate -> TriggerA () ()
    function1 = …
    
    rule party = do
      …
      forA … (function1 party)