- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 04:36 AM - edited ‎05-28-2025 04:37 AM
I have duration type field available in Business application table .I want to make that field dropdown with specific values like 1day,2 day,3 day etc. I can not directly change type from Duration to Dropdown. I don't want to change column name ,if we will create new field then we would have to create new field with different column name .Also we have data available for existing field ,so we can not directly delete existing field and create new field .
My thought is ,We can copy the data for the existing field to new temp field and then we can delete the existing field and create the field with same column name and again map the data accordingly .
Please confirm if this is fine ,also help me how can i copy data from 1 field to another temporary field .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 06:15 AM
To determine the impact: if that duration field is custom then you will have to find at which all places you have used that, some business rule script, script includes, reporting etc
To copy duration field to string you can run fix script like this
var gr = new GlideRecord("tableName");
gr.addNotNullQuery('durationField');
gr.query();
while (gr.next()) {
gr.customStringField = gr.durationField.getDisplayValue();
gr.setWorkflow(false);
gr.update();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 04:45 AM
you should do this carefully as Duration holds value differently and you can store that value in some new string field.
but you will have to identify at which all places this Duration field was used.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 05:54 AM
@Ankur: Thanks for your response .Will there be any impact if we will delete existing Duration type field and create new field with same column name .We are using this field to map values from catalog item submitted to update data in server form mostly.
Also could you please tell me how can i copy duration field data to string field ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 06:15 AM
To determine the impact: if that duration field is custom then you will have to find at which all places you have used that, some business rule script, script includes, reporting etc
To copy duration field to string you can run fix script like this
var gr = new GlideRecord("tableName");
gr.addNotNullQuery('durationField');
gr.query();
while (gr.next()) {
gr.customStringField = gr.durationField.getDisplayValue();
gr.setWorkflow(false);
gr.update();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 07:55 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader