Skip to content
Discussions/App Development/DAML UI Template - multiple parameters to a choiceForum ↗

DAML UI Template - multiple parameters to a choice

App Development4 posts443 views4 likesLast activity Apr 2020
MA
ManishGroverOP
Apr 2020

Hi,

I am using the DAML App Template (React) and need to pass multiple parameters to exercise a choice on a template. How can I do that?

I tried the below in the sample code that comes out of the box (Asset has a choice Give that takes one parameter). But this doesn’t work.

actions={[
          [
            “Send Information”,
            (c, param1, param2, param3) => {
                exerciseSendInformation(c.contractId, {
                    param1: param1, param2: param2, param3 : param3
              });
            },
            “3 params?”
          ]
        ]}

Thanks for your help!

GE
georg
Apr 2020

With the current UI template you can’t unless you know two of the three parameters upfront when creating the component, in which case you can partially apply them and pass in the resulting function taking one parameter.

The Contracts component is really just meant as an example to be copied and modified, so you can simply adopt it to be more powerful. One idea for generalizing this component would be to be able to pass in arbitrary React components as column contents, which would make it more flexible.

AN
anthony
Apr 2020

Do you have example code showing how to make these partially applied (or fully applied) requests? It sounds from the above like @ManishGrover does have all the parameters he needs to pass.

GE
georg
Apr 2020
ManishGrover:

exerciseSendInformation(c.contractId, { param1: param1, param2: param2, param3 : param3 });

If you know all but param1 you could define the function as follows:

actions={[
          [
            “Send Information”,
            (c, param1) => {
                exerciseSendInformation(c.contractId, {
                    param1: param1, param2: param2, param3 : param3
              });
            },
            “3 params?”
          ]
        ]}

You now have a function that just takes one parameter, which you can use in the actions array in the template. But I think the original question was if the template supports multiple parameters defined via user input - and it does not (currently).

← Back to Discussions