Issue with nested CDTs and a!writeToDataStoreEntity

We have a nested data model but our CDT's are flat so we save the parent first and use the PK to save the children. I think this is the recommended practice as there are issues with nested cdt's. The problem I am having is with the new 16.2 a!writeToDataStoreEntity expression that allows saving cdt's from SAIL. When saving nested structure on SAIL form we will have two a!writeToDataStoreEntity calls - one for parent and other for all children which gives the attached error. Is there a way to work around this? Is this something that will be fixed in future releases?

OriginalPostID-220503

OriginalPostID-220503

  Discussion posts and replies are publicly visible

  • a!writeToDataStoreEntity(
    dataStoreEntity: cons!XYZ,
    valueToStore: local!xyz,
    onSuccess: {
    a!save(
    local!xyz,
    fv!storedValues
    )
    }
    ),
    a!save(
    ri!pqr.id,
    repeat(
    length(
    ri!pqr
    ),
    index(local!xyz, 1, null).id
    )
    ),
    a!writeToDataStoreEntity(
    dataStoreEntity: cons!PQR,
    valueToStore: ri!pqr,
    onSuccess: {
    a!save(
    ri!pqr,
    fv!storedValues
    )
    }
    )
  • We are also trying to do this. Same problem. We will switch back to start a process in background.
  • Hi Gents,
    It is possible to save to nested CDTs using this function.

    consider the following CDTs:
    w2ds_parent(
    pkid (number pk auto),
    textfield (text),
    w2ds_child (w2ds_child)
    )
    //

    w2ds_child(
    pkid (number pk auto),
    textfield (text)
    )
    //

    On your submit button, the saveInto syntax is as follows:

    saveInto: {
              a!writeToDataStoreEntity(
                        cons!w2ds_parent,
                        'type!{urn:com:appian:types}w2ds_parent'(
                                  textfield: local!parentText,
                                  w2ds_child: 'type!{urn:com:appian:types}w2ds_child'(
                                            textField: local!childText
                                  )
                        )
              )
    }


  • I think the initial question was not about how to save nested CDTs, but how to save two flat CDTs one being parent and the other being child which needs the parent ID. AFAIK this can only be done in two steps.
  • @Rob...that would work if we had the @OneToMany in the parent cdt.....this limitation makes me think it might be good idea to have nested versions of cdt's as well....for such scenarios