- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 09:11 PM
Need to check if a catalog variable exist or not via Business Rule from Requested Item table.
Any suggestion please
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 09:13 PM
@lvillasenor Yes there is one of way to achieve same :
// Define the variable name you want to check
var variableName = 'your_variable_name';
// Check if the variable exists in the current Requested Item
if (current.variables[variableName]) {
gs.info("Variable '" + variableName + "' exists in Requested Item: " + current.number);
// You can also access the value using: current.variables[variableName].getDisplayValue()
} else {
gs.info("Variable '" + variableName + "' does not exist in Requested Item: " + current.number);
}
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 10:38 PM
Hi @lvillasenor ,
You can do below in your BR.
if(current.variables['your variable name here'])
do something
else
do something else
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 09:13 PM
@lvillasenor Yes there is one of way to achieve same :
// Define the variable name you want to check
var variableName = 'your_variable_name';
// Check if the variable exists in the current Requested Item
if (current.variables[variableName]) {
gs.info("Variable '" + variableName + "' exists in Requested Item: " + current.number);
// You can also access the value using: current.variables[variableName].getDisplayValue()
} else {
gs.info("Variable '" + variableName + "' does not exist in Requested Item: " + current.number);
}
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 10:38 PM
Hi @lvillasenor ,
You can do below in your BR.
if(current.variables['your variable name here'])
do something
else
do something else
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------