How to show historical data on asset record in activity?

BijoyDeb
Tera Contributor

Hi All,

 

For some reasons in our instance, Asset CI field mappings were inactive for few columns.

For eg, Assigned to

 

Due to which if an asset is assigned to somebody from someone, that change was not tracked in activities.

I made this mapping for asset and ci for Assigned to as active true.

 

But, now the thing is even if CI has assigned to person, thats not reflected on related asset.

Lets say if I wrote fix script to take assigned to from CIs and populate on Assets, how can I handle historical data.

 

For eg, if CI A was assigned to Abel first, then it got assigned to Abraham and now its with Peter. (During this time Asset CI field mapping was inactive)

 

Now, if I ran fix script and my asset will show Peter from Empty as Assigned to in activities.

But what about previous assignees (i.e. Abel and Abraham)?

 

How can show that transition in activities of my asset?

 

Please let me know how we can handle this?

 

Thanks!!

1 ACCEPTED SOLUTION

Robbie
Kilo Patron
Kilo Patron

Hi @BijoyDeb,

 

The table to check and obtain this data is the 'sys_history_line' table. Type 'sys_history_line.LIST' into the Navigation menu and hit enter. This will open the table in a separate tab for you.

 

One really important aspect to consider when interacting and viewing this table is the sheer size due to the fact it records pretty much all changes - so be sure if you are going to query and build a script from this you need to make sure your script is mindful of the size and only handles the data it needs to. For example make sure you limit it to a date range if possible and most importantly only the field and table required - for example the script only queries the alm_hardware table and the field of assigned_to only so as to limit the data/query.

 

See the screen shot below highlighting your exact scenario from my PDI which show both the Audited record change as well as the non-audited change of the Assigned to.

 

Screenshot 2024-10-03 at 16.19.18.png

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

View solution in original post

4 REPLIES 4

Voona Rohila
Kilo Patron
Kilo Patron

Hi @BijoyDeb 

Did you enable audit for that particular field and make sure that field is enabled in the activity too.

 

Reference Links : 

Enable auditing for a table

Include a table field in auditing

 

 

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

@Voona Rohila Yes, that is audited and I have included in Activity as well!

 

If your fix script is using setWorkflow(false) while updating records then the history wont be captured


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Robbie
Kilo Patron
Kilo Patron

Hi @BijoyDeb,

 

The table to check and obtain this data is the 'sys_history_line' table. Type 'sys_history_line.LIST' into the Navigation menu and hit enter. This will open the table in a separate tab for you.

 

One really important aspect to consider when interacting and viewing this table is the sheer size due to the fact it records pretty much all changes - so be sure if you are going to query and build a script from this you need to make sure your script is mindful of the size and only handles the data it needs to. For example make sure you limit it to a date range if possible and most importantly only the field and table required - for example the script only queries the alm_hardware table and the field of assigned_to only so as to limit the data/query.

 

See the screen shot below highlighting your exact scenario from my PDI which show both the Audited record change as well as the non-audited change of the Assigned to.

 

Screenshot 2024-10-03 at 16.19.18.png

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie