- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2017 05:46 PM
Hi everyone,
I have a requirement to update one of our workflows to trigger a new catalog tasks IF 3 conditions are met. The three include:
1) IF a checkbox on the sys_user table is set to true
2) IF a CI assigned to the current user has the chassis type set to 'Desktop' on the cmdb_ci_computer table
3) IF a CI assigned to the current user has the install status set to 'Installed' on the cmdb_ci_computer table
I'm able to get #1 accomplished just fine, it's # 2 and #3 that I'm having trouble with. I have attached some screenshot's that hopefully better explains my requirement. I have also attached the if 'activity in the workflow that I started with. Any help is appreciated. Thanks everyone!
Fred
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2017 09:17 PM
Hello Fred,
Please find the modified code below as per your req.
answer = ifScript();
var chasisStatus = CheckChasis();
var installStatus = CheckInstall();
function ifScript()
{
if(current.variables.u_lit_hold && chasisStatus && installStatus)
{
return true;
}
else
{
return false;
}
}
function CheckChasis()
{
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('assigned_to', gs.getUserID());
gr.addQuery('chassis_type', 'Desktop');
gr.query();
if(gr.next())
{
return 'true';
}
}
function CheckChasis()
{
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('assigned_to', gs.getUserID());
gr.addQuery('install_status', 1);
gr.query();
if(gr.next())
{
return 'true';
}
}
Note: Untested code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2017 09:17 PM
Hello Fred,
Please find the modified code below as per your req.
answer = ifScript();
var chasisStatus = CheckChasis();
var installStatus = CheckInstall();
function ifScript()
{
if(current.variables.u_lit_hold && chasisStatus && installStatus)
{
return true;
}
else
{
return false;
}
}
function CheckChasis()
{
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('assigned_to', gs.getUserID());
gr.addQuery('chassis_type', 'Desktop');
gr.query();
if(gr.next())
{
return 'true';
}
}
function CheckChasis()
{
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('assigned_to', gs.getUserID());
gr.addQuery('install_status', 1);
gr.query();
if(gr.next())
{
return 'true';
}
}
Note: Untested code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2017 11:43 PM
Hello Fred,
Let me know if that answered your question. If so, please mark it as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list. Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2017 11:50 PM
Hi Pradeep,
Thank you for the quick reply and for the sample code! I just got done testing this and was able to get it to behave the way I wanted, except for when the 'Installed Status' is set to a value of '1'. Even when the installed status is NOT set to '1' it still triggers the task. I even updated the GlideRecord to point to 'cmdb' (Base Configuration) instead of 'cmdb_ci_computer as the 'install status' is not on this table it turns out. I'll play with it some more, but this got me a lot closer to where I need to be. Thanks again!
Fred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2017 11:41 PM
HI Fred,
Please find the code below
- answer = ifScript();
- function ifScript() {
- var chasisStatus = false;
- var gr = new GlideRecord('cmdb_ci_computer');
- gr.addQuery('assigned_to', gs.getUserID());
- gr.addQuery('chassis_type', 'Desktop');
- gr.query();
- if(gr.next())
- {
- chasisStatus = true;
- }
- var installStatus = false;
- var gr1 = new GlideRecord('cmdb_ci_computer');
- gr1.addQuery('assigned_to', gs.getUserID());
- gr1.addQuery('install_status', 1);
- gr1.query();
- if(gr1.next())
- {
- installStatus = true;
- }
- if(current.variables.u_lit_hold && chasisStatus && installStatus)
- {
- return 'yes';
- }
- else
- {
- return 'no';
- }
- }
Hope this helps you.