Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Send latest attachment in outbound REST API call

Saquib Mohammed
Mega Guru

My process flow is somewhat like this - 

Step 1 - Create incident task and add attachment (e.g. File 1) to the task

Step 2 - Trigger the process to Send incident task details along with attachment to a third party using outbound REST integration

Step 3 - At a later point in time, add another attachment (e.g. File 2) to the same incident task and update work notes with the attachment details.

Step 4 - Trigger the process to Send the latest attachment with the work notes to the third party using the same outbound REST integration that was used in step 2

 

My query is related to Step 3. How do I identify which is the latest attachment, In the above example, how do i determine that File 1 was added earlier and File 2 is added now.

1 REPLY 1

Tony Chatfield1
Kilo Patron

Hi, I would follow this process

1/ Trigger task integration
Once task is successfully integrated (normally in the same script)
2/ Immediately check for any existing attachments for the task and then trigger attachment integration(s) for each record.

Then
3/ Using an after insert BR on sys_attachment table, if the table_name is integrated IE 'incident_task' check to see if task record (table_sys_id) is integrated, if yes trigger attachment integration for the current record using details from the integrated task to construct your payload.