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

Feroz1
Tera Contributor

Sorry it was my mistake, I have written two business rules so it is over riding . Now the code is working fine.