DAML script createCmd syntax
- alex_mOP 1
Hello,
I am trying to write an initialisation script for my app.
I have something like:
submit alice do createCmd Product with isProcessed = False description = "Coffee for Starbucks" owner = alice ...I am getting an error (highlighted underneath the first ‘=’). This goes away if I assign all on one line and with semicolons:
submit alice do createCmd Product with isProcessed = False; description = "Coffee for Starbucks"; owner = alice;This is not ideal because the
Producthas many fields. How can I assign on newlines?Thanks again!
N.B: Error also arises with newlines + semicolons
- cocreature 4
DAML is indentation sensitive. When you start a new block via
do,with, … you have to align nested blocks further than the previous block. In this case the block started by thedois aligned at the start ofcreateCmdso the block started bywithneeds to be indented further.
Here is an example that works:submit alice do createCmd Product with isProcessed = False description = "Coffee for Starbucks" owner = aliceYou are free to indent the block even further.
What you can do as well which I would personally do here is to insert a line break after thedoso thatcreateCmdcan move a bit further to the left. Here’s an example:submit alice do createCmd Product with isProcessed = False description = "Coffee for Starbucks" owner = alice - alex_m
Oh, dunno why I didn’t do that! Cheers