Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/DAML script createCmd syntaxForum ↗

DAML script createCmd syntax

App Development3 posts393 views5 likesLast activity Aug 2020
AL
alex_mOP
Aug 2020

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

CO
cocreature
Aug 2020

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
AL
alex_m
Aug 2020

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

← Back to Discussions