Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Update user record from workflow?

Sandy7
Tera Expert

Hello everyone,

I have a catalog item with a workflow attached. 

After one of the tasks is closed in the workflow, I need to update the sys_user table (user record). There is a checkbox field called "sensitive_employee" that I want to be checked. 

So on the catalog item form, there is a "Requested For" variable, and the user record for that person is where this update needs to happen. 

So far I have a run script activity in the workflow that looks like this, but now luck. Any ideas? thanks!

var gr =new gliderecord("sys_user");
var ga = "u_sensitive_employee";
ga.setValue("u_sensitive_employee", 'true');
gr.update();

 

5 REPLIES 5

Musab Rasheed
Tera Sage

Hello,

Here is the script

var requestedfor= current.variables.requested_for;
var gr= new GlideRecord("sys_user");
gr.addQuery('sys_id', requestedfor);
gr.query();
if(gr.next()){
gr.u_sensitive_employee = true;
gr.update();
}
Please hit like and mark my response as correct if that helps
Regards,
Musab