- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 04:53 AM
Hi Folks,
We have made a field as string by mistake. Now we need to change it to integer. We have stored only integer value in the field also but in string format.
Is there any way to convert the data type as integer.
Thanks in advance.
Vikash
Solved! Go to Solution.
- Labels:
-
Best Practices
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 05:02 AM
HI Vikey,
Fix script sample:
var gr = new GlideRecord("TABLENAME");
gr.addNotNullQuery('INTEGERFIELDNAME');
while(gr.next()){
gr.STRINGFIELDNAME = gr.INTEGERFIELDNAME.toString();
gr.update();
}
post me your feedback
Please Hit ✅Correct, â�ï¸�Helpful, or â�£ï¸�Like depending on the impact of the response
Have a lovely day ahead
Regards,
Divya Mishra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 04:56 AM
HI Vikey, It's not a best practice to chnage thed filed type you need create a one more field and field name should be diffrent then current filed once field is created you can chnage the lable of field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 05:00 AM
Thanks Chandu for the quick reply.
I have some another concern also. As there are lots of records in that field and it is used in reporting also. But now we are facing the issue as some users are able to submit the records as ten in place of 10.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 05:06 AM
Hi Vikey, if you have any exiting data in that field don't delete that field you need to write an on change script to take only integer don't create any integer field and copy thi data it's not a good idea Ex: if you have any exsiting data in letters it won't copy to integer field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 04:58 AM
If you change data type now, it would wipe out all existing data in the field. Try creating a new field of type integer and transferring data to the new field. You can run a one-time script to copy the existing data. Later change the data type and re-copy the same back again.
Let me know if this approach works for you.