Skip to content
Discussions/App Development/How to use template B's variable inside Template A choice?Forum ↗

How to use template B's variable inside Template A choice?

App Development5 posts138 views1 likesLast activity Jun 2023
AR
arijitltimOP
Jun 2023

I have two different template(A and B) and both are in different file.

Now I am planning to execute one choice for A template and want to validate one of the field of Template B.

In the below snapshot, LoanRequest is Template A and SyndicatePledge is Template B.
I want to execute the DisburseRequest choice only when the below conditions are satisfied.I am not able to use SyndicatePledge.totalPledge in this choice.

Kindly suggest.

ST
stefanobaghino-da
Jun 2023

You will need to pass a contract ID of a SyndicatePledge contract to the DisburseRequest choice, and in its body fetch it and access the totalPledge of the contract you just fetched. You might want to have a look at this page to see an example of a choice using another contract’s data.

AR
arijitltim
Jun 2023

I tried but still getting error.

image

ST
stefanobaghino-da
Jun 2023

SyndicatePledge is a template, not a contract. You will need to instantiate a contract of that template and pass contract ID for the instance in which you are interested. In the example I linked above, notice how the Merge choice has an otherCid argument of type ContractId Asset. You will need something analogous, with something along the lines of pledge: ContractId SyndicatePledge.

AR
arijitltim
Jun 2023

It’s working now. Thanks for the help.

← Back to Discussions