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 susana,

    As per my understanding from your description you just want to know how to update a record using write to DB smart service, if that is the case, try below steps.
    1. Before your write to DB smart service take one script task and in output of task map your new value (make sure your primary key field also have value, the one row id which you want to update) in your cdt .
    2. next to script task take Write to DB smart service, under input tab, Map your cdt type in "Data Store Entity" attribute (Value field), you can give any name for Name field than click on "New Input", here in value field map your cdt (one which contain values to update and value for Primary key).

    In Write to DB smart service , when you specify Id (primary key) it work as Update DB, if your P.K is null, it create new entry.

    Regards,
    Simple Shah
Reply
  • Hi susana,

    As per my understanding from your description you just want to know how to update a record using write to DB smart service, if that is the case, try below steps.
    1. Before your write to DB smart service take one script task and in output of task map your new value (make sure your primary key field also have value, the one row id which you want to update) in your cdt .
    2. next to script task take Write to DB smart service, under input tab, Map your cdt type in "Data Store Entity" attribute (Value field), you can give any name for Name field than click on "New Input", here in value field map your cdt (one which contain values to update and value for Primary key).

    In Write to DB smart service , when you specify Id (primary key) it work as Update DB, if your P.K is null, it create new entry.

    Regards,
    Simple Shah
Children
No Data