Can we put do blocks directly in templates?

A question related to this ( i guess )

Can we write “do” block in template ( or not under any choice ) ? if yes, can you share a sample snippet doing same?

in my case

template A
with
partyA : Party
where
signatory partyA
do ( gives error as : parse error on input ‘do’ )

1 Like

Good question, do blocks are Actions which are impure so they can’t be used directly in templates (you’d typically use them in Updates in Choices or in Scripts).

What’s the intended use case for wanting do in the template itself?

1 Like

Exploring DAML.

What’s the intended use case for wanting do in the template itself?

When a “ContractB” gets created ( using template ) it must eventually pull multiple contract of type “ContractA” and then get dataset(thought of using “do” here) from each “ContractA” to proceed with next action/choice.

Can you instead fetch those contracts in a choice?

yes… but isn’t that a multiple/extra action? first call contract and then exercise choice