- 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-20-2017 09:31 AM
I would take it as a good advice from a great person ctomasi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 05:02 AM
In some cases, you can change a string field to another type (e.g. HTML, or Journal), but you cannot change it when the underlying data type is different (e.g. String to Integer.)
As others have suggested, create a new integer field, copy the contents, and deactivate (or delete) the old field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2021 02:28 PM
If I change string to HTML or journal, does that also wipe out existing data?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 05:04 AM
I feel the data type change will be allowed if the data types are compatible.
I would advise you to try this on a demo instance first.
Edit: Checked on my dev instance(Helsinki) and changing string to int is not possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 05:06 AM
In demo instance I tried by changing string field to integer but its readonly after saving.
Do any one know or have the list of data types that are compatible with each other?