Setting date/time field using business rule only if the field is blank

Debbi L
Tera Expert

I'm attempting to set a "start date" date/time field to the current date/time based upon the criteria that one field is true, and the "start date" field is empty. I've been able to make it set the date/time initially (that part works perfectly); however, every time I send a new update, it changes the date to the current time, even though the "start date" field is populated. I've done an exhaustive search, and can find nothing that remediates this. Help!

I'm sure I'm missing something simple. This is the relevant code:

__________

When: Before, on Insert or Update

I've done this with and without filter conditions: Send to Legal is true, Legal start date is empty

_________

 

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

if (current.send_to_legal=='true' && (!current.legal_start_date.nil())) {

current.legal_start_date = gs.nowDateTime();
}

})(current, previous);

1 ACCEPTED SOLUTION

palmen
Tera Guru

You can do this with condition on the BR so it only runs if it's empty

find_real_file.png

View solution in original post

20 REPLIES 20

Fixed and marked, thanks.