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

Use debug all and set field watcher to this field to see what is happening.

Did that, and saw...nothing relevant.

0:55:17 (385)x_ccir_contracts_contract_services.doadded render event for ui_policy_onLoad
10:55:17 (390)x_ccir_contracts_contract_services.do[00:00:00.257] form rendered
10:55:17 (539)x_ccir_contracts_contract_services.dorunning inline scripts, count: 0
10:55:17 (540)x_ccir_contracts_contract_services.dorunBeforeRender
10:55:17 (560)x_ccir_contracts_contract_services.do[00:00:00.003] Stop Time Worked Timer
10:55:17 (561)x_ccir_contracts_contract_services.do[00:00:00.000] onLoad calcReturn
10:55:17 (562)x_ccir_contracts_contract_services.doGlideTabs2 findTabIndexByID could not find x_ccir_contracts_contract_services.REL:8f576281c3100200e280dccdf3d3aed8
10:55:17 (562)x_ccir_contracts_contract_services.do[00:00:00.001] onLoad Hide related lists
10:55:17 (562)x_ccir_contracts_contract_services.do[00:00:00.000] onLoad Hide doc_id if Parent filled
10:55:17 (563)x_ccir_contracts_contract_services.do[00:00:00.001] CS - Remove Closed State from Selection
10:55:17 (575)x_ccir_contracts_contract_services.do[00:00:00.011] CS short_description info bar
10:55:17 (577)x_ccir_contracts_contract_services.do[00:00:00.001] onLoad Modify Comments Label
10:55:17 (593)x_ccir_contracts_contract_services.do[00:00:00.013] ui_policy loaded
10:55:17 (596)x_ccir_contracts_contract_services.dorunAfterAllLoaded, functions: 53
10:55:17 (665)x_ccir_contracts_contract_services.dofireAllChangeHandlers start
10:55:17 (666)x_ccir_contracts_contract_services.dofireAllChangeHandlers end
10:55:17 (680)x_ccir_contracts_contract_services.dolate load functions: 7
10:55:17 (756)x_ccir_contracts_contract_services.doClearing event handlers reference cache
10:55:17 (757)x_ccir_contracts_contract_services.do[00:00:00.162] runAfterAllLoaded finished
10:55:18 (060)x_ccir_contracts_contract_services.doafter page loaded starting
10:55:18 (075)x_ccir_contracts_contract_services.do[00:00:00.014] GwtListEditor onTableLoad, tables examined: 4
10:55:18 (088)x_ccir_contracts_contract_services.do[00:00:00.028] after page loaded complete, functions called: 9
 

Yea, however, I'm confused and we just need to change it, lol. So make it work with == ''. 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Debbi L
Tera Expert

So, final update...

All of your suggestions worked. It was the field that was wonky (and I still don't know why). I created a new date/time field, plugged it into the old Business Rule, and everything works like a charm. I'm chalking this up to ghosts in the machine.

Thank you all for your time and expertise!

-Debbi

Yea...I figured it was something else. Ideally you would pick the first response that was the right answer as that right answer, but at least if you can, please mark all replies that were helpful to you as helpful.

 

Pretty sure you got about 4 responses all within 10 minutes, but some came in with more information than others. Up to you.

 

In the end, it works. Glad for that!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!