- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2018 06:50 AM
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);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2018 06:59 AM
You can do this with condition on the BR so it only runs if it's empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2018 07:31 AM
In that case I would enable debug in the instance and set the field watcher to this field so you can see what is actually happening to the field. It could be that there are some other scripts doing something to this field as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2018 07:33 AM
No such luck. Changed the BR order, same result. Changed the order of the filter conditions, same result.
Here's an oddity...
I removed the flags for insert and update, so there are zero conditions upon when the business rule should run. I get the SAME RESULT.
These are two fields the I just created, so there are no other rules or scripts running against them. Now I'm really confused.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2018 07:37 AM
When using the conditional tools, can you share a screenshot of that section of the BR? Preferable ALL of the BR, on that page?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2018 07:39 AM
Another thing, if you go back to scripting try this instead:
if (current.send_to_legal == true && current.legal_start_date != '') {
Notice I remove the 'true' and made it true too.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2018 08:02 AM
This script is saying if send_to_legal is true, and legal_start_date is NOT empty, correct? Because I only want this to run if legal_start_date IS empty.
I think I might have to go back to the drawing board on all of this, because I'm now finding that the field is changing even when the BR is disabled. There are no scripts, no other BRs, and the fields are only on this table. I am completely stumped.