Execute UI Action from REST API

Zach Biewend1
Giga Expert

The release team wants to automate their Change Requests through the API. They are able to create and update a change, but they also want to request approval. This is a UI Action on the change_request table. Is there a way to execute that (and others) UI action via the REST API?

The workaround I have in mind is to add a field to the table (u_api_request_approval [true/false]) and allow them to update it (to true). Then I can have a business rule that checks for that value and executes the scripts accordingly.

1 ACCEPTED SOLUTION

geoffcox
Giga Guru
3 REPLIES 3

geoffcox
Giga Guru

Just create a processor that calls the approval code.



Tutorial 4 Creating a Custom Processor - ServiceNow Wiki


This worked well from a human's perspective. I could enter the URL for the processor and it would execute my script. But my business partners were not able to hit that endpoint programmatically. What I ended up doing for this was using the REST import API. I created a custom import set row table and put some logic in that. I have them pass the sys_id as a POST call, then my script on the transform map uses the sys_id to grab the change_request record and perform the necessary actions.


Aleksas Kucins1
Giga Expert

Hi,

Not sure if correct answer is still relevant with recent ServiceNow versions, but you can call any UI action with REST API or XMLHttpRequest without the need to copy the UI action script to your scripted API. All you need from the UI action is the sys_id.

See link to my blog: https://servicenowthink.wordpress.com/2019/01/07/how-to-call-any-ui-action-with-rest-api-or-ajax-ser...