
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 07:38 AM
Note : Not a global table and it is set as read-only, as the name simplifies it counts the number of days Open.
Issue Details:
I'd like the "Days Open" field to only be integers and stop putting the additional .0 after the values. We don't use it.
I also want to ensure this number field is able to be sorted appropriately and actually do numerical order smaller to largest and vice versa. Right now, if I try to sort cases on Days Open they won't go in numerical order and go off the front number regardless of how high the number is (e.g., 209.0, 21.0, 211.0, 2112.0, 214.0).
Note : can we do this without scripting i.e., scriptless or else if we can use scripting what would be the logic.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 06:30 PM
Hey Chalan,
Chuck is correct in that you need to create a backup of that field's values. I have just tested a way to do this without exporting and importing and it's going to involve creating a temporary integer field to hold all of those values. It's very simple actually.
My method is going to require a mix of manual and scripting:
1. Create a new temp field on your table with type=integer
2. Run this script which will transfer all of your days_off [String] values to the days_off_temp [Integer] field. Something like this:
var gr = new GlideRecord('[YOUR TABLE HERE]');
// Add any extra queries here
gr.query();
while(gr.next()) {
gr.u_days_open_temp = gr.u_days_open;
gr.update();
}
I just tested it and it does automatically convert the string version to integer version just by setting the value. No need for any extra parsing call.
3. Confirm that all of your data was successfully transferred to the temp field before continuing to step 4
4. Go to the dictionary table and delete your days_open field
5. Recreate your field and set it to the correct field type of Integer
6. Run the same script except now your transferring from days_off_temp to days_off (look at line 6)
var gr = new GlideRecord('[YOUR TABLE HERE]');
// Add any extra queries here
gr.query();
while(gr.next()) {
gr.u_days_open = gr.u_days_open_temp;
gr.update();
}
7. Confirm that all of your integers have transferred to the original field 'days_open'
8. Delete the temp field when not needed anymore
Sorting should not be a problem anymore at this point.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2017 03:46 AM
Hi John,
Thank you the logic worked fine and definitely it was very helpfull.
Regards,
chalan