How to get the primary ID in a Write to Multiple Data Store Entities Smart Service

Dear all,

In my process model, I am currently using several Write to Data Store Entity smart services (all the CDTs are in the same Data Store) as follows:

1. Write to Data Store Entity (insert into the request table and get the ID from the output)

2. Script Task (Use the output above to set the IDs for request items)

3. Script Task (Again use the output above to set the IDs for approvers list)

4. Write to Data Store Entity (insert into the request items table)

5. Write to Data Store Entity (insert into the approvers list table)

Can someone confirm to me if all the above data operations can be done with a single Write to Multiple Data Store Entities Smart Service?  If the answer is yes, how do I get and set the ID returned from the first operation?

Thanks

  Discussion posts and replies are publicly visible

Parents
  • Hi, 

     It's not doable to execute above-mentioned use case using single data store activity but requires at least two data store activities 

    1. Perform step # 2,3 on the output of  Write to Data Store Entity (Request) activity.

    2. Use Write to Multiple Data Store Entities( Request & approvers list) activity to perform step #4,5  

    Thanks, 

  • This is not necessarily true - if you define a nested CDT, you can insert the data into all tables in a single transaction and the IDs for child CDTs will be generated and applied to the parent CDT automatically. If you do this, you wouldn't even need the Write to Multiple Data Store Entities; you can use the standard Write to Data Store Entity.

    That being said, nested CDTs have other drawbacks and I would only suggest using them in a narrow set of use cases (namely 1:1 and 1:M relationships). In most cases the steps provided above are correct (and if you have already implemented it this way I wouldn't change it). For more information, please see the documentation on CDT guidance.

Reply
  • This is not necessarily true - if you define a nested CDT, you can insert the data into all tables in a single transaction and the IDs for child CDTs will be generated and applied to the parent CDT automatically. If you do this, you wouldn't even need the Write to Multiple Data Store Entities; you can use the standard Write to Data Store Entity.

    That being said, nested CDTs have other drawbacks and I would only suggest using them in a narrow set of use cases (namely 1:1 and 1:M relationships). In most cases the steps provided above are correct (and if you have already implemented it this way I wouldn't change it). For more information, please see the documentation on CDT guidance.

Children