How to get id of inserted record inside process model?

Scenario: 

Insert record in to DB and return the record details back including the index ID of the record.

How to get the Id and save into process variable?

I have tried to save ac!storedvalues into target process variable, but the variable is not having ID value when it passed to user input task (the next step after writing new record to DB).

Please see the screenshot of the process model for nodes being used and the configuration of output of write to DB smart service.

The script task in the below image is not configured and is empty. please ignore this node. immediately after write to db the next node should be user input task.

Please share a recipe or screenshot how to get dynamically the new entry record ID

  

  Discussion posts and replies are publicly visible

Parents
  • I would remove the Custom Output into nasRequest.id, as the Stored Values -> nsaRequest is correct above. Also verify in your XSD that the ID column is annotated with "@Id @GeneratedValue", or in the /design interface that "Auto-generate the next unique identifier.." is selected after clicking on the Key icon.
  • removed it. but still doesn't work, refer to new screenshot of Task where Asset Id is coming empty after saving the record in DB with write to db node. yes, selected auto-generate next identifier option after selecting the primary key icon on the CDT. Is this a problem? Below is the xsd element for ID

    <xsd:element name="Id" nillable="true" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">@Id @GeneratedValue</xsd:appinfo>
    </xsd:annotation>
    </xsd:element>

Reply
  • removed it. but still doesn't work, refer to new screenshot of Task where Asset Id is coming empty after saving the record in DB with write to db node. yes, selected auto-generate next identifier option after selecting the primary key icon on the CDT. Is this a problem? Below is the xsd element for ID

    <xsd:element name="Id" nillable="true" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">@Id @GeneratedValue</xsd:appinfo>
    </xsd:annotation>
    </xsd:element>

Children
No Data