Can changing the type from Duration to Integer in dictionary will Capture only days for a field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 12:08 AM
Hi
Have a Requirement that need to capture only the days for a duration field.
Business doesn't want to delete the existing field which is of type Duration and It has the data for 7k records.
So can clearing the field through fix script and changing the type of the field to Integer will fix ?
after clearing the field how to populate the Integer value for the historical records?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 03:47 AM
Hi,
It is not recommended to change the type of any dictionary. Also you will not be able to change its type from Duration to Integer.
In such cased we should always create a new field and start using new field. Once all configurations are done you can write fix script to copy data of existing field to new custom field (by converting it in the expected format/type).
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 07:49 AM
Thank you Anil for the explanation. Is the below fix script correct? is the new field will have only days?
u_days_onhold is the duration field
u_days_onhold1 is the new field created and is of integer type
var gr = new GlideRecord("incident");
gr.addEncodedQuery('u_days_onholdISNOTEMPTY');
gr.query();
while (gr.next()) {
gr.u_days_onhold1=gr.getValue('u_days_onhold');
gr.setWorkflow(false); //Do not run business rules
gr.autoSysFields(false); //Do not update system field
gr.update();
}