- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 08:27 AM
I am trying to create a IF statement inside a Workflow to see if the request.requested_for is a Internal employee.
Any suggestions?
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 06:47 PM
Hi,
As the others have mentioned, unfortunately you didn't provide much information for us to assist you...but...the code to query a table would look like:
answer = ifScript();
ifScript() {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', current.request.requested_for);
gr.addQuery('u_internal_employee', 'true');
gr.query();
if (gr.next()) {
return 'yes';
} else {
return 'no';
}
}
So here you would want to look at replacing "u_internal_employee" with the name of the field on the user record where you are tracking if they are internal or not? I just assumed it was called u_internal_employee and it was a checkbox returning "true" meaning it was checked.
If so, the path out of the if statement activity in your workflow would go out of the yes route or if they weren't, it would go out of the no path.
Or if you're trying to look for a specific role, then:
answer = ifScript();
ifScript() {
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('user', current.request.requested_for);
gr.addQuery('role', 'sys_id_of_role');
gr.query();
if (gr.next()) {
return 'yes';
} else {
return 'no';
}
}
Where you'd want to replace "sys_id_of_role" with the sys_id of that role.
My code above is merely an example to get you started.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 05:32 PM
Hi,
I am assuming you want to validate this based on the snc_internal role?
-Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 02:17 PM
Hi
I want validate if the table for each Report if they table has a value in the column.
For example:
answer = ifScript();
function ifScript() {
// This table name
var reg = new GlideRecord('u_power_bi_azure_lookup');
//This is the name of the report
reg.addQuery('u_report_name', "Portfolio Metrics Report");
//This is the name of the column, that have empy fields depending of the Report. If an azure ad group is there it generate a task to add the user to an ad group if the field is empty it should skip this step and goes to the next step.
reg.addQuery('u_internal_azure_ad_group', '');
reg.query();
if (reg.next()){
return 'yes';
}
else {
return 'no';
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 06:39 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 06:47 PM
Hi,
As the others have mentioned, unfortunately you didn't provide much information for us to assist you...but...the code to query a table would look like:
answer = ifScript();
ifScript() {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', current.request.requested_for);
gr.addQuery('u_internal_employee', 'true');
gr.query();
if (gr.next()) {
return 'yes';
} else {
return 'no';
}
}
So here you would want to look at replacing "u_internal_employee" with the name of the field on the user record where you are tracking if they are internal or not? I just assumed it was called u_internal_employee and it was a checkbox returning "true" meaning it was checked.
If so, the path out of the if statement activity in your workflow would go out of the yes route or if they weren't, it would go out of the no path.
Or if you're trying to look for a specific role, then:
answer = ifScript();
ifScript() {
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('user', current.request.requested_for);
gr.addQuery('role', 'sys_id_of_role');
gr.query();
if (gr.next()) {
return 'yes';
} else {
return 'no';
}
}
Where you'd want to replace "sys_id_of_role" with the sys_id of that role.
My code above is merely an example to get you started.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!