How to fetch the mid server properties value in mid server scripts in servicenow tokyo version
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 01:37 AM
We have defined a custom property in mid server properties.
How to fetch those propert value in mid server scripts.
For example:
To fetch the configuration parameters we use the below script in mid server scripts includes script:
// Get mid server details
this.SNOWusername = ms.getConfigParameter('mid.instance.username');
this.SNOWpassword = ms.getConfigParameter('mid.instance.password');
this.SNOWurl = ms.getConfigParameter('url');
this.SNOWProxyHost = ms.getConfigParameter("mid.proxy.host");
this.SNOWProxyPort = ms.getConfigParameter("mid.proxy.port");
this.SNOWProxyUsername = ms.getConfigParameter("mid.proxy.username");
this.SNOWProxyPassword = ms.getConfigParameter("mid.proxy.password");
And the corresponding values will be returned.
Similarly I have defined a custom property 'use_default_param' with value 'true' in mid server properties.
How to fetch the above property value in the above script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2023 05:19 AM
Hi @Aishwarya NG ,
To fetch the value of a custom property in a MID Server script, you can use the getConfigParameter function with the name of the custom property as the parameter. Here is an example script that fetches the value of a custom property called use_default_param:
// Get custom property value
this.useDefaultParam = ms.getConfigParameter('use_default_param');
// Use the custom property value
if (this.useDefaultParam == 'true') {
// Do something
} else {
// Do something else
}
In this example, the value of the use_default_param custom property is stored in the this.useDefaultParam variable. You can then use the value of the custom property in your script logic as needed. Note that the value of the custom property is returned as a string, so you may need to convert it to a boolean or other data type depending on your use case.
If my response helps you to resolve the issue close the question by ✅Accepting solution and hit 👍thumb icon. From Correct answers others will get benefited in future.
Thanks,
Ratnakar