- 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-20-2025 05:33 AM
Hello Ankur
Sadly this did not work. It resulted in false even though the chosen server was on the cmdb_ci_win_server table. Any suggestion as for how to debug this?
Thanks
- 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-21-2025 06:16 AM
This also worked! Thank you, Ravin 🙂
- 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 🙂