Update table business rule delete

Nadey
Tera Contributor

I need to update a field in a table only when all the records in another table with a specific field type have been deleted. I am using a Business rule with the "Delete" on when to run. 

my business rule script:

var user = current.u_userid;

var product = current.u_product; <----- need to check this field

var arr[];

 

var  gr = new gliderecord('sys_user');

gr.addquery('sys_id', user);

gr.query();

if(gr.next()){

gr.setvalue('myfield', true);

gr.update();

}

 

Thanks 

5 REPLIES 5

sonali panda1
Kilo Sage

First you are doing delete operation on some table. Once data is deleted then you are updating on user table?

 

I am doing delete on a custom table, the field needs to be updated on the user table. In the custom table the field I need to check is u_product, if this has the value of "hardware" and only one records has been selected to be deleted then the flag in the user table is not updated. If all the records with "hardware" have been deleted from the custom table then the field is update in the user table. 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So what debugging have you performed?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

In the current state the field in the user table is updated but I need it only update when all the records with u_product are deleted.