Database Insert using Write to Data Store Entity Smart Service

Hi All,

I have had good success using the Write to Data Store Entity Smart Service to INSERT rows into database tables using CDTs. I thought there will be an Update Database Smart Service just like there is a Delete from Data Store Entity but I read on Appian documentation that the Write to Data Entity is the same smart service used to UPDATE database rows. I also tried to find examples without success.

The Write to Data Store Entity accepts a Data Store Entity node input but I am having a hard time finding the parameter where I can specify the id for the primary key of the table and also I cannot see the parameter where I can specify which column in the database I want to update, and lastly the new value.

As an example, my CDT looks like this:

id,
department,
type,
currentStatus

For the above CDT, I am trying to set the value of currentStatus to "Initiator Rework" for the row with id coming from pv!requestData.requestId. How can I configure the Write To Data Store Entity to achieve this?

Thanks

  Discussion posts and replies are publicly visible

Parents
  • Hi,

    Does your CDT is annotated with @Id @GeneratedValue annotations?
    If yes, your CDT will look like below:
    id(Primary key which is autogenerated)
    department
    type
    currentStatus

    As you mentioned pv!requestData.requestId - this field is not in your CDT. id and requestID fields are same ?

    To insert new record in DB,
    id[null]
    department-pv!requestData.department
    type-pv!requestData.type
    currentStatus-pv!requestData.currentStatus

    To update the record:
    id-pv!requestData.id[this is the primary key for request table]
    department-pv!requestData.department
    type-pv!requestData.type
    currentStatus-pv!requestData.currentStatus
Reply
  • Hi,

    Does your CDT is annotated with @Id @GeneratedValue annotations?
    If yes, your CDT will look like below:
    id(Primary key which is autogenerated)
    department
    type
    currentStatus

    As you mentioned pv!requestData.requestId - this field is not in your CDT. id and requestID fields are same ?

    To insert new record in DB,
    id[null]
    department-pv!requestData.department
    type-pv!requestData.type
    currentStatus-pv!requestData.currentStatus

    To update the record:
    id-pv!requestData.id[this is the primary key for request table]
    department-pv!requestData.department
    type-pv!requestData.type
    currentStatus-pv!requestData.currentStatus
Children
No Data