When the user's account is deactivated. We have to pull the list of ticket numbers assigned to the user and paste them in the newly created field on the user record?

Feroz1
Tera Contributor

I have a field free text field in user table. Once the user's account is deactivated. We have to pull the list of ticket numbers assigned to the user and paste them in the newly created field(free text field in user table) on the user record.

Please help me with approach and scripting. Thanks in advance.

 

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

HI @Feroz

Create after update business rule and give condition as active is false and use below script:

(function executeRule(current, previous /*null when async*/ ) {
    var sysID = [];
    var gr = new GlideRecord("task");
    gr.addQuery("assigned_to", current.getUniqueValue());
    gr.query();
    while (gr.next()) {
        sysID.push(gr.getValue("number"));
    }
    current.field_name= sysID.toString();  //give your field name where you want to update the ticket numbers...
    current.update();


})(current, previous);

Hope it helps..

Thanks,
Murthy

Thanks,
Murthy

View solution in original post

5 REPLIES 5

Murthy Ch
Giga Sage

HI @Feroz

Create after update business rule and give condition as active is false and use below script:

(function executeRule(current, previous /*null when async*/ ) {
    var sysID = [];
    var gr = new GlideRecord("task");
    gr.addQuery("assigned_to", current.getUniqueValue());
    gr.query();
    while (gr.next()) {
        sysID.push(gr.getValue("number"));
    }
    current.field_name= sysID.toString();  //give your field name where you want to update the ticket numbers...
    current.update();


})(current, previous);

Hope it helps..

Thanks,
Murthy

Thanks,
Murthy

Feroz1
Tera Contributor

@Murthy Chintalapudi 

 

The above code is not working,

I have written BR after update on user(sys_user) table and condition given when active is false.

created one field (string type) on user table task he has inactive.

var sysID = [];
    var gr = new GlideRecord("task");
    gr.addQuery("assigned_to", current.getUniqueValue());
    gr.query();
    while (gr.next()) {
        sysID.push(gr.getValue("number"));
    }
    current.u_task_he_has_inactive= sysID.toString();  //give your field name where you want to update the ticket numbers...
    current.update();

 

@Murthy Ch ,

 

I have a similar requirement that I thought you might be willing to assist me with solution-ing. I have been asked to send a notification upon user deactivation to alert their manager of the ACTIVE tasks that need to be reassigned to another assignment group member. Should I be concerned about performance issues when querying the 'task' table? Please let me know your thoughts. Thanks in advance!

Murthy Ch
Giga Sage

Hi Feroz,

Keep some logs and check what is not working.

BTW do you want to put only the active tasks or all of the tasks?

If it is active tasks then add gr.addActiveQuery(); before the gr.query();

 

Thanks,

Murthy

Thanks,
Murthy