Table of Contents

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

  1. Before Insert (Record) Event
  2. Add Action - “Retrieve Value for Control” & Set
    1. Control Name = CREATE_USER_ID
    2. Source Type = Session
    3. Source Name = UserLogin

CREATE_DT

Steps

  1. (Add another) Before Insert (Record) Event
  2. Add Action - “Retrieve Value for Control” & Set
    1. Control Name = CREATE_DT
    2. Source Type = Expression
    3. Source Name = time()

UPDATE_USER_ID

Steps

  1. Before Update (Record) Event
  2. Add Action - “Retrieve Value for Control” & Set
    1. Control Name = UPDATE_USER_ID
    2. Source Type = Session
    3. Source Name = UserLogin

UPDATE_DT

Steps

  1. (Add another) Before Update (Record) Event
  2. Add Action - “Retrieve Value for Control” & Set
    1. Control Name = UPDATE_DT
    2. Source Type = Expression
    3. Source Name = time()

Formatting

Set both CREATE and UPDATE date to the following date format to display the full date with time

mm/dd/yyyy h:nn:ss AM/PM

And to the following for the dbformat

yyyy-mm-dd HH:nn:ss

Other consideraions

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

 CCGetSession("UserLogin") 

CREATE_DATE

In the default value property

 CurrentDateTime