Create env variables in service now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 08:23 PM
How to create env variables as key value pairs and can it be used it in service now script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 12:59 AM
Are you trying to make any REST call from your business rule ? If yes, ServiceNow recommends to use async to make REST calls from business rule in scoped application. If you try to use after insert/update then system won't allow to save the business rule.
Still, if you want to continue with the insert/update business rule only, you can try adding/modifying the below lines of code to the business rule script :
var response = r.executeAsync();
response.waitForResponse(10);
Here, instead of execute() method, we make the REST API call asynchronous by calling executeAsync() method.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 09:35 PM
Create a sys_properties as like below:
1.Navigate to sys_properties.LIST.
2.Click 'New'.
3.Name the sys property as needed and set the type as JSON
4.In the value create as like below example.
{
Home: rest,
School : Educate,
Office: work
}
5.You can access this propery from server side as like below example:
var envVar= gs.getProperty('passthe prop name');
var Parse = JSON.parse(envVar);
gs.log(parse[0]);
gs.log(parse[1]);
gs.log(parse[2]);
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 11:32 PM
I have configure same and wrote business script then getting error message : Illegal access to outbound HTTP in demo. Use an async business rule to perform outbound HTTP requests.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 11:46 PM
You can change the type of business rule to Async instead of after in when to run condtion...
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 11:39 PM
Hi pavan yadav1,
You can use Flow Designer to create an action.