- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 07:10 AM
Hi everyone
I have a workflow (for change requests) that needs to have an IF condition that is triggered by the operating system of the server chosen as Configuration Item (cmdb_ci) on the change form. For instance, it should evaluate to TRUE if the server is running Windows.
No matter what I try, I can't get it to evaluate to "true". I've tried scripts that look at whether the operating system field contains the word "Windows". I've also tried a script that looks at whether the CI is on the cmdb_win_server table but still, it results in a "false" even though the chosen server/CI clearly is on that table. Example:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 06:04 AM
Hi @Jens Mogensen ,
Please try this script:
(function executeCondition(current) {
if (!current.cmdb_ci) {
return false;
}
var ci = current.cmdb_ci.getRefRecord();
if (ci && ci.instanceOf('cmdb_ci_win_server')) {
return true;
}
return false;
})(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 07:33 AM
I found a solution. I used this script in stead:
It checks whether the model_id value of the chosen CI contains the word Windows. Not as sophisticated as looking at which table the CI was on, but that seemed to be part of the issue I am guessing. Model_id was a field present on the whole cmdb_ci table while the other scripts had to take the value of cmdb_ci and then find out which table it was on. I would have thought that this was possible but apparently not.
Regardless, this gives me the exact same result I was looking for so it's all good. Thank you for the suggestions 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 07:43 AM
you can use this in IF script
var ci = current.cmdb_ci.sys_class_name;
if (ci == 'cmdb_ci_win_server') {
// it's windows server
} else {
// it's not
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 08:24 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 05:20 AM
I will test it at once and get back to you. Thank you 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 05:24 AM
Sure, do mark my response as correct if it helped.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader