Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:codecharge:setting_audit_columns [2014/11/15 09:13]
tech:codecharge:setting_audit_columns [2014/11/15 09:13] (current)
Line 1: Line 1:
 +====== Auto populate CREATE/​UPDATE USER_ID and CREATE/​UPDATE DT on inserting/​updating a record ======
 +Almost every Codecharge form needs to auto populate create and update audit fields. Here is how it can be done.
 +
 +===== CREATE_USER_ID =====
 +Steps
 +  - Before Insert (Record) Event
 +  - Add Action - "​Retrieve Value for Control"​ & Set
 +    - Control Name = CREATE_USER_ID
 +    - Source Type = Session
 +    - Source Name = UserLogin
 +
 +===== CREATE_DT =====
 +Steps
 +  - (Add another) Before Insert (Record) Event
 +  - Add Action - "​Retrieve Value for Control"​ & Set
 +    - Control Name = CREATE_DT
 +    - Source Type = Expression
 +    - Source Name = time()
 +
 +===== UPDATE_USER_ID =====
 +Steps
 +  - Before Update (Record) Event
 +  - Add Action - "​Retrieve Value for Control"​ & Set
 +    - Control Name = UPDATE_USER_ID
 +    - Source Type = Session
 +    - Source Name = UserLogin
 +
 +===== UPDATE_DT =====
 +Steps
 +  - (Add another) Before Update (Record) Event
 +  - Add Action - "​Retrieve Value for Control"​ & Set
 +    - Control Name = UPDATE_DT
 +    - Source Type = Expression
 +    - Source Name = time()
 +
 +===== Formatting =====
 +Set both CREATE and UPDATE date to the following date format to display the full date with time
 +<​code>​mm/​dd/​yyyy h:nn:ss AM/​PM</​code>​
 +And to the following for the dbformat
 +<​code>​yyyy-mm-dd HH:​nn:​ss</​code>​
 +
 +==== Other consideraions ====
 +  * Make all create userid/date NOT required
 +  * Make all create/​update userid/date read-only
 +  * Make all field the same size and remove any blank spaces around the controls. Size 20 seems to work well.
 +  * Appreance
 +    * Group all audit fields in one row with four columns
 +    * Delete the date pickers
 +    * Add a blank row about the four column row and label it with "​{res:​audit_field_div}"​
 +    * Update the Locale for the above as "​Create User/Date & Update User/​Date"​
 +
 +====== Alternate way to auto populate CREATE_USER_ID and CREATE_DT on new record ======
 +This method should not be used because it does not set the insert date on the time of insertion. It sets it when the blank record is loaded and the date will not be accurate. The User id on the other hand is fine. 
 +
 +===== CREATE_USER_ID =====
 +In the default value property ​
 +<​code>​ CCGetSession("​UserLogin"​) </​code>​
 +
 +===== CREATE_DATE =====
 +In the default value property ​
 +<​code>​ CurrentDateTime </​code>​
  

QR Code
QR Code tech:codecharge:setting_audit_columns (generated for current page)