DAML script createCmd syntax

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 Product has many fields. How can I assign on newlines?

Thanks again!

N.B: Error also arises with newlines + semicolons

1 Like

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 the do is aligned at the start of createCmd so the block started by with needs to be indented further.
Here is an example that works:

  submit alice do createCmd Product with
                   isProcessed = False
                   description = "Coffee for Starbucks"
                   owner = alice

You 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 the do so that createCmd can 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
4 Likes

Oh, dunno why I didn’t do that! Cheers