Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Need to change user to active false using background script.

Vyanktesh08
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

Community Alums
Not applicable

@Vyanktesh08  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 @Vyanktesh08 ,

 

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

 

 

Goka Srinu
Tera Contributor

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

GokaSrinu_0-1730565147470.png

Hope this will help you.