Ah!! By 'not allowed' I meant that it was not using my record change -- but I was using EXECSTAT = 1 as well!
I missed the EXECSTAT = 2 ... I only had 0 (fail) and 1 (write) as valid choices -- I missed the "2". Let me try my code with a "2" and see -- that's likely my whole issue ... Thanks Jeff! -----Original Message----- From: Jeff Butera [mailto:[email protected]] Sent: Sunday, October 09, 2011 10:41 PM To: [email protected]; [email protected] Subject: Re: [U2] UniData Update Triggers On 10/09/2011 08:46 PM, David Wolverton wrote: > During an Update Trigger, I'd like to alter the 'Current Record' as passed > into the trigger so the 'effective written' record is different with changes > I want to make, but it appears the change is not allowed. I'm not sure I understand "not allowed" - are you getting an errors? > I have some logic that would be "easy" to add into a trigger to modify a few > fields that otherwise I get to hunt through every relevant 'write' in BASIC > -- worse, I will miss the ability to do this field update if the records is > AE edited. That's the whole point of EXECSTAT: 0 = don't write the record 1 = write record as passed in, ignoring any changes made in trigger 2 = write record as edited by trigger This example will overwrite field 1: SUBROUTINE MY_TRIGGER_SUB(X.EXECSTAT,X.DICT,X.FILE,X.ID,X.REC) X.EXECSTAT=2 X.REC<1> = 'Happily overwriting fields in this record' RETURN I use this for stored computed columns and other things that sound similar to what you want. Here's a real example that sets a slew of default values anytime a record is written: SUBROUTINE H08.T.H08.JA.SEARCH(X.EXECSTAT,X.DICT,X.FILE,X.ID,X.REC) X.EXECSTAT=2 IF X.DICT = '' THEN * record changed who/date/time X.REC<5> =UPCASE(@LOGNAME) X.REC<3> =DATE() X.REC<4> =TIME() IF X.REC<17> ="" THEN * record added who/date/time X.REC<17> =X.REC<5> X.REC<1> =X.REC<3> X.REC<2> =X.REC<4> END * Default values... * Next Question=1 IF X.REC<25> = '' THEN X.REC<25> = 1 END * Num apps IF X.REC<46> = '' THEN X.REC<46> = 0 END * Status=Search Creation IF X.REC<10> = '' THEN X.REC<10> = 'SC' X.REC<11> = DATE() END * Accept Resumes=NO IF X.REC<20> = '' THEN X.REC<20> = 'N' END * Cull method=view all apps IF X.REC<23> = '' THEN X.REC<23> = 'A' END END RETURN -- Jeff Butera, PhD Manager of ERP Systems Hampshire College 413-559-5556 _______________________________________________ U2-Users mailing list [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users
