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.

Adding Dynamic Approvers to Requested item using Api

abhi182000
Giga Contributor

I have a requirement where I have a catalog item. 
When the catalog item is submitted, an RITM(sc_req_item) is created. 

My requirement is as follows : 
1. RITM is created 
2. For the approval stage the list of approvers is not present in SNOW , I need to trigger an api to a 3rd party app and the api will send a response with the list of approvers based on the variables selected in the catalog item

So basically Once the RITM is created I need to trigger this api and get the response and populate the approval list.
How can i achieve this? 

I have a workflow attached to this catalog item 
Can i write a script and call the api in the 'advanced' section of the 'approval activity ' in the workflow? 
OR 
Should i run a buisness rule /script include which will call the api and get the response? 
If so could you please mention the flow of this? 


I have 2 levels of approvals . So can I do it directly in the approval action script? 

I have attached the image of the approval activity. 

 

I'm just starting out with automations in SNOW. Any help would be appreciated 
Thank you in advance 🙂

1 REPLY 1

DrewW
Mega Sage

I would use a script activity to trigger the call to the web service and also pass over the requested item with the info.  Then add a "Wait for WF Event" activity to the workflow.  From there you can have the 3rd party service make a call back to a scripted rest service to indicate if the request was approved or not and then all you have to do is record that in a workflow var and trigger the workflow event to get the workflow to move forward.  After that its just a matter of checking the workflow var to see if you need to mark the requested item as approved or rejected.