How to manage scripted REST API calls between instances?

JayGervais
Kilo Sage

I have created a workflow for updating laptops in ServiceNow with integrations into Google Admin and InTune. Based on the catalog choices by the user, the workflow triggers a series of REST API calls to these services to complete the actions, some of which include removing the device.

This is all great except that I am not sure how to prevent these API calls from actually being made to our production accounts in sub-prod. I am not sure what the best practice would be for something like this? Is it common to create a clone script or exclusion for scripts like this?

I appreciate the insight.

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, I use a clone ‘Cleanup script’ to update my Application registry\authentication records and change the authentication URL’s\endpoints to the corresponding dev integration target, during clone.
You could also use the clone script to set the auth record inactive if the integration has no dev instance, I set mine inactive and change the endpoints so that dev integration needs to be physically enabled post clone.

In the integration scripts I also manage url domains dynamically based on the OOB property ‘instance_name’ as this is always the current instance.

gs.info(gs.getProperty('instance_name'));

Thank you for the suggestion Tony. Clone cleanup scripts were my first thought but it was challenging to target a workflow script. For my solution, I ended up creating a class in a script include to store all my API scripts that get called within the workflows. This way, I can target just the one script easily in a clone cleanup script to deactivate it. I also used the instance_name property to only allow them to trigger in our prod instance.