Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Need to change user to active false using background script.

VyankteshK
Tera Contributor

Hi Team,

I need to change user active false using background script. I am using below script, but record of user is not changing to active false.

 

var gr = new GlideRecord('sys_user');

gr.addQuery('sys id', '62826bf03710200044e0bfc8bcbe5df1');
gr.query();
if (gr.next()) {
    gr.active = "false";
    gr.setWorkflow(false);
    gr.update();
}
3 REPLIES 3

Not applicable

@VyankteshK  Active field should be set boolean  (true/false) and sys_id is right field , please try below script:

var gr = new GlideRecord('sys_user');

gr.addQuery('sys_id', '62826bf03710200044e0bfc8bcbe5df1');

gr.query();

if (gr.next()) {

    gr.active = false; // Set as boolean

    //gr.setWorkflow(false); // Disable workflows if you don’t want it to trigger any

    gr.update();

}

 

Hope this will help you.

Runjay Patel
Giga Sage

Hi @VyankteshK ,

 

replace   gr.active = "false"; with   gr.active = false.

 

 

Goka Srinu
Tera Contributor

@VyankteshK  use "sys_id" instead of "sys id"

GokaSrinu_0-1730565147470.png

Hope this will help you.