Create env variables in service now

pavan yadav1
Tera Contributor

How to create env variables as key value pairs and can it be used it in service now script ?

9 REPLIES 9

Hi @pavan yadav1 

 

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.

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @pavan yadav1 

 

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....

LinkedIn - Lets Connect

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.

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....

LinkedIn - Lets Connect

Muhammed Medni
Tera Guru

Hi pavan yadav1,

You can use Flow Designer to create an action.