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

Aman Kumar S
Kilo Patron

Hi @pavan yadav1 

You have dictionary type Name- value field type.

 

You can refer to below doc how to script these types of field:

https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/field-admini...

 

Best Regards
Aman Kumar

Maddysunil
Kilo Sage

@pavan yadav1 

I think you can use system properties to store key-value pairs that act as environment variables for your scripts. These properties can then be accessed and utilized within your ServiceNow scripts.

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

Amit Verma
Kilo Patron
Kilo Patron

Hi @pavan yadav1 

 

You can create system property to store key-value pairs as JSON and then read and parse it inside your script using below syntax :

 

var input = gs.getProperty('name of your system property');
parsedInput = JSON.parse(input);

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

getting error message when i am doing trigger business rule script : Illegal access to outbound HTTP in demo. Use an async business rule to perform outbound HTTP requests.

Business rule script : 

(function executeRule(current, previous /*null when async*/) {
 
var input = gs.getProperty('my_json_property');
    parsedInput = JSON.parse(input);
 
})(current, previous);