Business rule not working

Rosy14
Tera Guru

I have a BR which is runing on factory table. in fac record there is a field case. when fac record is rejected that case will be closed below BR is not working.

 

Rosy14_0-1718868641909.png

Action:

 

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

    // Add your code here
    gs.addInfoMessage("before "+current.parent.state);
    current.parent.state = 3;
    //current.parent.active = false;
    current.update();
    gs.addInfoMessage("after "+current.parent.state);
})(current, previous);
 
also tried:
Rosy14_1-1718868730225.png

 

info msg coming as 

Rosy14_2-1718868766633.png

 

but case is not closed

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@Rosy14 Please update the script as follows.

 

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

    // Add your code here
    gs.addInfoMessage("before "+current.parent.state);
    var parentRec = current.parent.getRefRecord();
    parentRec.state = 3;
    //current.parent.active = false;
    parentRec.update();
    gs.addInfoMessage("after "+current.parent.state);
})(current, previous);

Hope this helps.

View solution in original post

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@Rosy14 Please update the script as follows.

 

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

    // Add your code here
    gs.addInfoMessage("before "+current.parent.state);
    var parentRec = current.parent.getRefRecord();
    parentRec.state = 3;
    //current.parent.active = false;
    parentRec.update();
    gs.addInfoMessage("after "+current.parent.state);
})(current, previous);

Hope this helps.

Rosy14
Tera Guru

Thanks. working now.