Update Details in User History Audit

georgechen
Kilo Guru

Hi SNOW Gurus

I was wondering if I could get your assistance on an user record history question.     Previously I have asked   if a account deletion details could be captured by a script at Re: History Details - Is there a way to capture when a user account gets deleted by script

But that was not exactly the question meant to be asked.     Is any way to added the following lines in purple to the User History (Detail Users -> right click -> History -> Calendar see 150908_User_History_detail_extract.PNG for the original calendar view extract )

user changed from Adam Turner-Duplicate to Adam Turner in 1 cmn_notif_device records

user changed from Adam Turner-Duplicate to Adam Turner in 2 cmn_notif_message records

Duplicate record: adam.turner@communties.qld.gov.au-Duplicate has been deleted

Additional info:

1) The sys_user auditing is turned on,

2) Tables contains history,

Asset History                                                                               u_cmdb_ci_ast_history

Contract History                                                                     clm_contract_history

Discovery Device History Log                           discovery_device_history_log

Escalation History                                                                 sysrule_escalate_history

History                                                                                                   sys_history_line

Label history                                                                               label_history

Record History                                                                     sys_history_set

Record View History                                                         u_dms_document_view_history

Replication History                                                           sys_replication_history

Transform History                                                           sys_import_set_run

Visual Task Board Card History                   vtb_card_history

Workflow Activity History                                       wf_history

Workflow Transition History                             wf_transition_history



Thanks guys

George

1 ACCEPTED SOLUTION

georgechen
Kilo Guru

Hi guys



I think I have managed to find a way to achieve this, and would like to share the way I am implementing.   Basically none of the above tables are used to insert any audit records. Instead a new custom field is created, called u_duplicate_remove_ref



In the UI Action Processing Script, I added a variable to store the deletion details, and then update the this new field.


In the replacement user -> Navigate to History -> Calendar -> You can view the Before and After field change on this new field, which log the removal steps description.



The above happens to do what was expected and I will leave it to you guys to see if there is a better way to achieve this.



Thanks,


George





                              var update_notes='';


                                              while (device.next()) {


                                                    gs.print('Deleting Notification Device');


                                                    gs.print('User:' & device.user);


                                                    gs.print('Type:' & device.type);


                                                    gs.print('Email Address:' & device.email_address);


update_notes += 'Email Address: ' & device.email_address & ' deleted\n;' ;


device.deleteRecord();


                                              }



......


                              if(num>0) {


                                                                                                                              gs.addInfoMessage(dict.element+' changed from '+usr1.getDisplayValue()+' to '+usr2.getDisplayValue()+' in '+num+' '+dict.name+' records');


// update duplicate_ref_notes var


                                                                                                                              update_notes += dict.element+' changed from '+usr1.getDisplayValue()+' to '+usr2.getDisplayValue()+' in '+num+' '+dict.name+' records' + '\n';


                               


                                  }


                                                              }


                                                              usr1.deleteRecord();


                                                             


                                                              gs.addInfoMessage('Duplicate record: '+usr1.user_name+' was deleted');


usr2.u_duplicate_removal_ref ='Duplicate Account '+usr1.user_name+' was deleted. \n' + update_notes;                


              usr2.update();


View solution in original post

1 REPLY 1

georgechen
Kilo Guru

Hi guys



I think I have managed to find a way to achieve this, and would like to share the way I am implementing.   Basically none of the above tables are used to insert any audit records. Instead a new custom field is created, called u_duplicate_remove_ref



In the UI Action Processing Script, I added a variable to store the deletion details, and then update the this new field.


In the replacement user -> Navigate to History -> Calendar -> You can view the Before and After field change on this new field, which log the removal steps description.



The above happens to do what was expected and I will leave it to you guys to see if there is a better way to achieve this.



Thanks,


George





                              var update_notes='';


                                              while (device.next()) {


                                                    gs.print('Deleting Notification Device');


                                                    gs.print('User:' & device.user);


                                                    gs.print('Type:' & device.type);


                                                    gs.print('Email Address:' & device.email_address);


update_notes += 'Email Address: ' & device.email_address & ' deleted\n;' ;


device.deleteRecord();


                                              }



......


                              if(num>0) {


                                                                                                                              gs.addInfoMessage(dict.element+' changed from '+usr1.getDisplayValue()+' to '+usr2.getDisplayValue()+' in '+num+' '+dict.name+' records');


// update duplicate_ref_notes var


                                                                                                                              update_notes += dict.element+' changed from '+usr1.getDisplayValue()+' to '+usr2.getDisplayValue()+' in '+num+' '+dict.name+' records' + '\n';


                               


                                  }


                                                              }


                                                              usr1.deleteRecord();


                                                             


                                                              gs.addInfoMessage('Duplicate record: '+usr1.user_name+' was deleted');


usr2.u_duplicate_removal_ref ='Duplicate Account '+usr1.user_name+' was deleted. \n' + update_notes;                


              usr2.update();