- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 09:58 AM
Hi All,
I have a workflow where I need to capture the sysid of user from the configured variable "term_user" which is referencing to "sys_user" table. If requester specify the user name then
script should capture the user value & get it's sys id.
Condition: If user is active then it should return true else false.
I have created the below script but it's always returning "no" as value. Can someone have a look & let me know the reason.
----------------------------------------------------------------------
//Script to check whether user is active or not.
answer = ifScript();
function ifScript() {
var t_user = current.variables.term_user.sys_id; //term_user is a variable where user is providing the user information
var user = new GlideRecord('sys_user');
user.addQuery(t_user);
user.query();
while (user.next())
{
if (user.active == true)
{
answer = 'yes';
}
else
{
answer = 'no';
}
}
-----------------------------------------------------------------------------------
Thanks in advance!
Kind regards,
Manish
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2017 10:21 AM
Thanks every one, by the below query I am able to get the proper result in workflow.
var t_user = current.variables.term_user;
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', t_user);
gr.query();
if (gr.next())
{
if (gr.active == true)
{
answer = true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 10:19 AM
No Jaspal, result is still coming as NO for active users even after changing it to Return.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 10:16 AM
Please use the below code in "if" block.
answer = ifScript();
function ifScript() {
if (current.variables.term_user.active == 'true') {
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 10:27 AM
Hi Arnab,
Aren't we have to glide the User table as workflow is in sc_cat_item table?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 10:30 AM
Please try the code. I believe it will work if you have added the variables in the sc_cat_item from the request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 10:33 AM
It didn't worked Arnab.