AnsweredAssumed Answered

Running a script independent of layout whenever a record is added

Question asked by docroc67 on Apr 1, 2018
Latest reply on Apr 2, 2018 by docroc67

I need to create a unique ID (called recordID) per record in a table (called Book) created by taking the first 3 characters of a field called index & the value of Get(RecordNumber) for the new record.  However, it needs to do this atcommit, not oncreate, because the user hasn't yet filled in the index field contents when the record is first created.  In addition, I need to check for empty index fields with some additional code -- these records will get filled in with the fixed prefix "NDX" plus the record number.


I've written a script that setup all the existing records just fine.  The issue is how to do new records.


* Using serial on the auto-enter tab of the field options for the recordID, I don't see a way to use a calculated result, though I know I can put alpha characters in the starting value.  But not, presumably a calculation containing an immediate IF(?)


* Using the calculation option, I can do exactly what I need, except that there's no option to choose between oncreate and oncommit, so my calculations keeps running as soon as the blank record is created and before the index field has been filled in by the user.


* I can write a script that does it based on a trigger for the layout (or for the index field), but there are numerous layouts that may add a record to this same table.  Do I need to put the script in a trigger event for each layout I want it to run on is there a global way to say "When a new record is created in Book, then run the script."?   Also, does the recordID field need to appear on all layouts or is its existence in the underlying table sufficient?


Thanks in advance,