Backup Field Automation for Tables

Utkarsha
Tera Contributor

Hey everyone,
We have migration going on in our project and
to handle our data migration, we need something that will create a new field in the target table to capture a backup of user and group reference fields.
Input attributes: Tables in scope (example: ['core_company', 'ticket'])
Expected behavior:
The functionality should create a backup field (name = u_backup, type = Name-Value Pairs).
The functionality should populate the field with values of user and group references.
For example, on an incident:
If there are assigned_to and assignment_group fields:
Expected result: {{

{'assigned_to': 'abel Tuter'', 'assignment_group': 'IT- developers'}
}}
Is there a way I can automate this process as this has to be applied for the entire table related data?

Any kind of help here would be greatly appreciated 👍

Thank you in advance!

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

"Is there a way I can automate this process as this has to be applied for the entire table related data?" - The obvious answer is to use a script to cycle over every record in your table and populate this field.

 

However, can you expand on what your data migration activity is? Performing whatever migration you're doing inside a fix script would allow you to record a rollback context. The rollback context would then allow for the holding of the previous values of the affected records without needing to add a new column to the current record.

 

View solution in original post

3 REPLIES 3

Kieran Anson
Kilo Patron

"Is there a way I can automate this process as this has to be applied for the entire table related data?" - The obvious answer is to use a script to cycle over every record in your table and populate this field.

 

However, can you expand on what your data migration activity is? Performing whatever migration you're doing inside a fix script would allow you to record a rollback context. The rollback context would then allow for the holding of the previous values of the affected records without needing to add a new column to the current record.

 

Hello @Kieran Anson ,

Thank you for your inputs on this.

We are going migrate all our data from current service now instance to a new instance. I will utilise fix script then to achieve this. One more thing I don't think servicenow support json type of dictionary creation...then should I use string type of field? Will that work.?

Thank you 😊 

For whatever reason, the JSON field type is set as non-selectable. You can view this by going to sys_glide_object and searching for JSON. The "visible" field is set to false.


If you feel comfortable with customising the record to mark it as visible, you'll then see the option when creating new dictionary entries