#GeneratedValue How to get auto generated value in process model. In CDT, t

#GeneratedValue
How to get auto generated value in process model. In CDT, there is an auto generated ID, but in the instance it not showing the auto generated ID. How can I see this ID in my process model. Thanks.

OriginalPostID-155011

OriginalPostID-155011

  Discussion posts and replies are publicly visible

  • Hi, If you are speaking about @GeneratedValue annotation set on a column in cdt xsd, then an auto generated value is assigned for that column when a record is written to database. Can you be more specific on whether you want to see ID in a model or in a process ?
  • @Goutham.
    How to get auto generated ID and how to update values for that particular ID.
  • HI Anil,
    Please navigate to your CDT, download the XSD, open and edit it. Add the following @ annotation to make your column as auto generated :
    <xsd:element name="idInt" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
    @GeneratedValue
    </xsd:appinfo>
    </xsd:annotation>
    </xsd:element>.
    Hope this is what you required.
  • 0
    Certified Lead Developer
    Based on your actual question I think you are using a CDT to insert into a table and want to pick up the auto-generated ID value? On the write to datastore node use the data output tab to save the "Stored Values" back into your CDT process variable, if your XSD is defined as mentioned above you will now have your id value.
  • Thanks Tim. I have done same thing, but the values are not updating for same ID. It is creating one new ID. In my process model using two Write to Datastores. One for Insert and the other for Update. In Insert write to datastore node ID is generating. Now I need to update the values for that generated ID.

    In Output at Stored Values passing CDT for Target field in both the Insert and Update write to data store nodes.
  • 0
    Certified Lead Developer
    And you have the @Id and @GeneratedValue annotations in your XSD definition of the CDT? Could you share your XSD or at least the primary Id element?
  • xs:sequence>
                                  <xs:element name="ORDR_SBMT_ID" type="xs:integer" nillable="false">
                                            <xs:annotation>
                                                      <xs:appinfo source="appian.jpa">
                                                      @Id
                                                      @Column(name="ORDR_SBMT_ID" columnDefinition="NUMBER NOT NULL")
                                                      @SequenceGenerator(name="orggenerator", sequenceName="ORDR_SBMT_ID_SEQ", initialValue=1)
                                                      @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="orggenerator")
                                                      </xs:appinfo>
                                            </xs:annotation>
                                  </xs:element>

    ID is generating, but how to get the auto generated ID? If I get the generated ID in process model, then I can pass the updated values to that ID.
  • Hi Anilkumark,
    Place a script task in between the two write to DB nodes and map the generated Id into a corresponding variable of the CDT.
    Hope it helps.