Catalog Item to set user values

Baggies
Kilo Guru

I receive numerous requests to manually activate user records in ServiceNow, ie set active=true, and locked_out=false, so that HR can complete termination tasks. They need the account active for a short amount of time. The user record will get updated anyway on the next import/update from AD.

I would like to do it from a catalog item, which HR can initiate themselves, so that I have a record. I created an item, and a workflow to go with it. The workflow activity (definition= run script) is where I am coming unstuck.

The variable on the item is 'activate_user', a reference to the sys_user table.

In the run script workflow activity, I would like to have the script activate the user, specified in the activate _user variable.

The script should be simple shouldn't it? Something like:

var user = current.variable_pool.activate_user;

user.active=true;

user.locked_out=false;

user.update();*/

Or would I have to build a query to query the user table for the user first? Also, I think there may be an ACL involved to, to allow HR to update the user record. Maybe there is a better solution? A custom application? Appreciate any help. Thanks

1 ACCEPTED SOLUTION

Your variable contains the sys_id of the User record.   You will need to use something like:


onSubmit(){


var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function


}


function doAlert(caller) { //reference is passed into callback as first arguments


    alert (caller.name +   " is active now ");


}




See Wiki on getReference:


GlideForm (g form) - ServiceNow Wiki


View solution in original post

7 REPLIES 7

Your variable contains the sys_id of the User record.   You will need to use something like:


onSubmit(){


var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function


}


function doAlert(caller) { //reference is passed into callback as first arguments


    alert (caller.name +   " is active now ");


}




See Wiki on getReference:


GlideForm (g form) - ServiceNow Wiki


Used the following based on reply:



function onSubmit(){


var caller = g_form.getReference('activate_user', doAlert); // doAlert is our callback function


}


function doAlert(caller) { //reference is passed into callback as first arguments


    alert (caller.name +   " will be active for 2 hours only ");


}


Thanks....appreciate it.