REST API: updating an incident should never create a new incident

jensst
Kilo Explorer

Hello,

I understand that it is possible to use the Service Now Rest API to post data to the import set table:Import Set API - ServiceNow Wiki

I can see that there are two supported methods:

1) POST /api/now/import/(staging TableName) Inserts a new record into the import set staging table.

2) GET /api/now/import/(TableName)/(sys_id) Retrieves a specific import set record and associated target records created as part of the transformation.

Now I would like to update a specific incident. I know it is possible to use the post method which will either insert a new incident or update an existing incident if the defined coalesce field in the transform map matches an existing record.

This is not exaclty what I try to achieve; I would like make sure only updates are performed. If there is no existing incident no new incident should be created.

Does anyone have an idea how to achieve this?

thanks and regards,

Jens

1 ACCEPTED SOLUTION

Christopher_Mal
ServiceNow Employee
ServiceNow Employee

Not sure if someone else already mentioned this, but I will add that you can use your import set table and have a simple transform script that ignores the action if the action is insert.  



You would include the following code in your transform script: (referenced in the wiki here: http://wiki.servicenow.com/?title=Transform_Map_Scripts#gsc.tab=0)



if (action == "insert")


  ignore = true;


View solution in original post

10 REPLIES 10

Thanks for your response. The problem I see with this approach is that we would need another GET request before the update operation. Since we are dealing with mass operations this might lead to performance issues.


Why can't you just directly use Table API Update method (put/patch)


Akash,


as far as I know direct Table API access is not recommended for updating/inserting records for third part integrations. (I've seen this in some Service Now integration video)


regards,


Jens


Jens,



Yeah, you are right. So for this we can use transform maps and use the power of transform scripts and ignore if action is insert.


The same is commented by Christopher below


Christopher_Mal
ServiceNow Employee
ServiceNow Employee

Not sure if someone else already mentioned this, but I will add that you can use your import set table and have a simple transform script that ignores the action if the action is insert.  



You would include the following code in your transform script: (referenced in the wiki here: http://wiki.servicenow.com/?title=Transform_Map_Scripts#gsc.tab=0)



if (action == "insert")


  ignore = true;