Business rule not working when inserting a record via REST API process

carlh
Kilo Guru

Good morning.   I need a script tweak...

I have a BEFORE Business Rule that is setting the value of Date field as a Time Stamp

find_real_file.png

find_real_file.png

Here's the script that runs when it meets this condition.

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

var now = new GlideDateTime();

current.u_inshold_glide_date = now;

})(current, previous);

This is working great when I update a record.

But, now we're inserting new records in our nightly process and I have another rule that is setting the "Insurance Hold?" to true on "Insert".   That worked over night but it did not set the "Insurance Hold Date" as it does when I update.   Then I went in to update and nothing changed.

Here's my question.   If I just make "Insert = True" on the business rule above, and change the condition to IS True rather than "CHANGES To True"   will it fix my issue?

The purpose of this is to put newly Inserted vendors on Insurance hold until someone has an opportunity to review their insurance documents.

What do you suggest?

6 REPLIES 6

We ended up with the following business rule and its working.



When = Before


Update = True


Order = 100


Condition = Boolean Field Changes




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



var now = new GlideDateTime();


if(current.u_boolean_field == false && previous.u_boolean_field == true){


    current.u_inactive_glide_date = now;


}



})(current, previous);



I forgot about this post.   Maybe I get the right answer?


mrswann
Kilo Guru

Mine was solved due to ACL: debug data lookup inserted via REST