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

I noticed that the user_name displays in parentheses where ever the name is displayed (i.e. Requested for, Assigned To, etc...).   Did you notice this when you did it?



Can you show me what your updated the code looks like?


Hi April,



Yes, this is what setting the Display Value field for a table does... wherever there is a reference field pointing to that table (e.g., "requested_for" on a Request) and you select a value in the reference field, it will display the value stored in whatever is that referred-to-record's Display field.   In this case for 'requested_for', it will look to the field on [sys_user] that you have set to Display=true.



When you change the display value field for a table, it is used everywhere.




-Brian


Hi Brian,



I followed your instruction and did the something in sys_user --> name --> calculated value


Am able to get the activity log with the name - department (e.g.: Joshwa - Finance)


But am getting the same format names in all user reference fields e.g.:- caller, opened_by, assigned to etc..


I just want to have   "name + department" only in activity log whenever the user updates not in every user reference fields.



Please help me


Nope...



This was a while ago, but I believe I deciphered the relationship between the audit and history tables empirically... that is, I know it's writing the user's display name to the user_name field in History, and that this is what gets displayed by the Activities Formatter... But I didn't find the mechanism that is actually doing this copying from audit-->history, so I don't know that you could customize it.   And as mentioned above, when you change the display value for something, you change it everywhere.



The only option I see left if you wanted something in the Activities that was not the user's display value, would be to write your own customized formatter xml to pull a different value from the [sys_user] table.   The history line table *does* have a reference to user, so it's possible.   But creating a formatter is something I haven't accomplished yet.   Will get back to you if I do.




Thanks,


-Brian


Hi Brian,

 

Modifying the value on name on the sys_user table to achieve what is required here will also reflect in other tables/fields where the user table is used as reference . Can you please help if there is any way to only affect the activity history.