Business Rule to Update Reference with Dot-walked value of another reference field

sarahyelton
Tera Expert

I have tried both before and after business rules.  Even if I have "insert" checked, they only ever work on update.  I have two reference fields on the same form.  I want to populate u_tac_business_app with the value of u_business_application (dot walked from the other reference field:  u_tac_record).  This is the current after BR I have.  Please help.

 

(function executeRule(current, previous /*null when async*/) {

current.u_tac_business_app = current.u_tac_record.u_business_application;

current.update();

})(current, previous);

1 ACCEPTED SOLUTION

Hello

Agreed with What dirk Said, Never  ever use current.update() in before business rule.

Check field name correctly:

(function executeRule(current, previous /*null when async*/) {

gs.log("Check Value :"+current.u_tac_record.u_business_application); /

current.u_tac_business_app = current.u_tac_record.u_business_application;

gs.log("Updated value"+current.u_tac_business_app);

})(current, previous);

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade

View solution in original post

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sarah,

never use current.update() in your before insert/update business rule

also in the code did you check by adding log statements what sys_id is coming?

also why to use script instead use set value

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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