This content has been marked as final. Show 8 replies
Thanks for your replies guys, The applet is being used in Edit List mode, the script is written on the BC. App version 184.108.40.206  SIA
Here is the code -
function BusComp_WriteRecord ()
if(this.GetFieldValue("Verification Flag") == "Y" && TheApplication().GetProfileAttr("SET_DATE") == "Y")
var SysDate = Clib.time();
var ObjDate = Date.fromSystem(SysDate);
var Month = ToString(ObjDate.getMonth()+1);
var Day = ToString(ObjDate.getDate());
var Year = ToString(ObjDate.getFullYear());
var Hour = ToString(ObjDate.getHours());
var Minute = ToString(ObjDate.getMinutes());
var Second = ToString(ObjDate.getSeconds());
var now = Month+"/"+Day+"/"+Year+" "+Hour+":"+Minute+":"+Second;
Just to wrap things up.
The original solution by using SetFieldValue (without WriteRecord) in the WriteRecord event should never have worked.
All the code that is written in the WriteRecord event is executed AFTER the changes have been saved to the database.
One scenario would be to update child records with the new values in the current record.
But also in that case you would still have to do a WriteRecord for the child records.
As you noticed you will need to do another WriteRecord to commit the SetFieldvalue in the WriteRecord event.
Putting your code in the PreWriteRecord event will mean that the SetFieldvalue in the code gets written to the database together with the other changes.
The fact that it worked with CTRL+S or CTRL-Arrow is a bug (in my opinion), even though it did give your wanted result.