Hello,
I have an object script trigger that sets the date/time value of a date/time field of another (id:12345) record. This trigger is being called from a "Validate Record Data" trigger for the record being created. However when trying to do so, the rbv_api.setFieldValue(...) fails to set the field value for the date/time fields. Could you please let me know when this would be fixed?
Validate Record Data trigger:
var nameValue = "{!name#text}"; if(nameValue !== ""){ rbv_api.runTrigger("object1", 12345, "setDateValue", true);
return 'Name cannot be empty'; }
Object Script Trigger:
var currentDate = rbv_api.getCurrentDate(); var value = new Date(); rbv_api.setFieldValue("object1", {!id}, "dateTimeField", value);
Cheers.
Iram
Hi IramK,
When creating/updating records from UI pages, Validation Triggers do not have transaction context set, they are evaluated only to check for validation failure. As such, your 'setDateValue' trigger is being called and executed but changes not persisted.
Thanks,
Nitin
Hello [mention:e5d6fd9a1d9042a6a3c7b20e0f22c213:e9ed411860ed4f2ba0265705b8793d05] ,
Thanks for your answer. My changes are not persisted only for the date/time field, however they are being updated for other fields like text field or a checkbox field. So my question really is: What exactly is the correct behavior? Should it update or not?
Cheers.
Iram
Hi Iram,
I included code in my 'setDateValue' object script trigger to also update text and boolean fields along-with date/time field. I noticed none of the three fields get updated.
Is this what you meant?
Do you also have code to update date/time, text, boolean fields inside single object script but only notice text/boolean fields getting updated?
Nitin
Hello [mention:e5d6fd9a1d9042a6a3c7b20e0f22c213:e9ed411860ed4f2ba0265705b8793d05] ,
Yep I have code to update date/time, text and boolean fields inside single object script but only text/boolean fields get updated and not the date/time. What might be the reason?
Also something really strange: Although the date/time field is not updated, but if I go in the object definition and modify any property of any field and save. The date/time field value is visible. Really weird!
Iram
Hi Iram,
We do not have transaction context for validation triggers. So, updates from inside validation triggers will not persist to database, validation triggers can only update them in-memory. Few values that you are seeing being updated could have been picked from memory by some other transaction initiated immediately after validations, and persisting in database as part of their normal update process. However, in memory changes are perishable and not reliable.
Please consider using validation triggers only for simple checks involving select queries and not actual update scripts.
Thanks,
Nitin
So, this isn't a bug with Rollbase and RB is behaving as expected if I understand this correctly?
Iram