How can I add the user ID to the activity log stamp in a record?

apriled
Tera Expert

I would like to add the userID in parentheses next to the username in the Activity Log when a record is updated.

AddUserID2ActivityLogStamp.jpg

1 ACCEPTED SOLUTION

Ok, figured it out.



The Activity formatter is pulling from the History [sys_history_line] table, which stores the audited changes (actually copies them from the audit table on-demand, but no need to get into that here), and it stores the value of a user's name field ([sys_user].name) in a string value called user_name on the History table.



All you need to do is edit the calculated value on the dictionary entry for column 'name' on the table [sys_user] to show the userid you want displayed.   I've (actually) tested this time, and it works.



**Keep in mind that this will not affect existing entries in the History table, those strings have already been written from the previous user name values.   However, you can clear (delete) the existing records from the History table and they will be regenerated from the audit table records.   So unless you clear the history table to have it rebuild the history lines, you will see the previous values (name only) for existing entries, and the new values (name + userid) for new entries.




-Brian




Edit:   To clear your history entries requires clearing two tables:   [sys_history_line] and [sys_history_set].   The easiest way is to open each from the "Tables" module, and then click the button "Delete All Records".


View solution in original post

10 REPLIES 10

Brian Dailey1
Kilo Sage

Hi April,



I believe the Activity formatter is just using the Display Value for the user record of the person making the updates.   So, all you would need to do is change the display value field on [sys_user] to include the information you want (i.e., the USERID).



  1. Open any user record
  2. Right-click the form header and choose Configure/Table
  3. Find the table column with a value of true for "Display"
  4. Click on that column to edit it in the Dictionary
  5. Change the script under the Calculated Value tab to return the information you want
    (Assuming this field is a calculated value)


That's it, now your Activity journal entries should show the new user display format.   Let me know if that doesn't work for you.




Good luck,


-Brian




Edit:     I take it back.   I thought that the audit records were relying on the user's Display Name, but it seems to be coded just to use the name field from [sys_user].   I'll look into it more to see where/if this can be customized.   Alternatively, you could create a custom Activities formatter for your purpose that will include the USERID, but this sounds like a lot more work.


Ok, figured it out.



The Activity formatter is pulling from the History [sys_history_line] table, which stores the audited changes (actually copies them from the audit table on-demand, but no need to get into that here), and it stores the value of a user's name field ([sys_user].name) in a string value called user_name on the History table.



All you need to do is edit the calculated value on the dictionary entry for column 'name' on the table [sys_user] to show the userid you want displayed.   I've (actually) tested this time, and it works.



**Keep in mind that this will not affect existing entries in the History table, those strings have already been written from the previous user name values.   However, you can clear (delete) the existing records from the History table and they will be regenerated from the audit table records.   So unless you clear the history table to have it rebuild the history lines, you will see the previous values (name only) for existing entries, and the new values (name + userid) for new entries.




-Brian




Edit:   To clear your history entries requires clearing two tables:   [sys_history_line] and [sys_history_set].   The easiest way is to open each from the "Tables" module, and then click the button "Delete All Records".


It worked!! Thanks for your help Brian.


Great!... That was a thinker.




-Brian