We use one generic recordAdd method for all new records.
It looks up which defaults are needed for the specific tenant, and sets common fields automatically in case they exist in the record, for example
- Code: Select all
// Set the create_date/create_user if the column is present in the table, from SERVER (all users have the same time base then...)
if (aColumnNames.indexOf("creation_date") > -1) rRec["creation_date"] = application.getServerTimeStamp() ;
if (aColumnNames.indexOf("creation_user_id") > -1) rRec["creation_user_id"] = scopes.person.currentPersonID ;
Then that method calls a submethod that is specific to the table.
In general, I try to code everything as generic as possible. I do not like when large chunks of code get duplicated somewhere.