Glide record taking a long time to process

pennieturner
Mega Guru

I need a little help to try and work out why a glide record I have created is taking a long time to process.

Background - I've set up a request for ServiceNow access.   Part of this request is to replace an existing persons license, so I am capturing the revoke date on the request (revoke_date).   I want to update the user record with this date (u_revoke_on - this is a manual field on the sys_user table) from the workflow.

I originally tried this:

current.user.u_revoke_on = current.variables.revoke_date;

but it didn't work, so I added a script in:

var gr = new GlideRecord('sys_user');

gr.addQuery('user' , '=', current.variables.replacing_user);

gr.query();

while(gr.next())

  {

  gr.u_revoke_on = current.variables.revoke_date;

  gr.update();

}

This works, but for some reason it takes ages to set the request up.   (If I remove it its instant)

Can anyone help me find out why when I include this in my workflow it takes ages?

Thanks in advance

1 ACCEPTED SOLUTION

pennieturner
Mega Guru

Its updating all records thats why its taking so long, I changed the query to be sys_id instead of name and it now works ok



var gr = new GlideRecord('sys_user');


gr.addQuery('sys_id' , current.variables.replacing_user);


gr.query();


while(gr.next())


  {


  gr.u_revoke_on = current.variables.revoke_date;


  gr.update();


}


View solution in original post

1 REPLY 1

pennieturner
Mega Guru

Its updating all records thats why its taking so long, I changed the query to be sys_id instead of name and it now works ok



var gr = new GlideRecord('sys_user');


gr.addQuery('sys_id' , current.variables.replacing_user);


gr.query();


while(gr.next())


  {


  gr.u_revoke_on = current.variables.revoke_date;


  gr.update();


}