Unable to change type of a table column.

Mouktik_B
Tera Contributor

I have a column inside a table of integer type but can't change its type. Only integer shows up when I try to change the type. what could be solution?

1 ACCEPTED SOLUTION

Bhimashankar H
Mega Sage

Hi @Mouktik_B ,

 

You won't be able to change the data type once column is created for your scenario. Here best to create new column with your specified data type.

 

If you want to retain the data then using bg script or fix script you can move/copy the data in your new column, apply proper data type conversion when data moving. Later based on your need either keep for any future use or delete the column.

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

View solution in original post

9 REPLIES 9

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Mouktik_B If you have only limited data, it’s better to identify the fields and create a new data type. Before you delete anything, make sure to take a backup of the data. Then you can safely delete the field. Please note that this will impact any scripts where the field has been used.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Shashank_Jain
Kilo Sage

@Mouktik_B ,

 

 

  • Why you can’t change it: Once a column is created as integer, ServiceNow doesn’t allow changing it to another type (only limited safe conversions are possible).

  • Solutions:

    1. Best practice → Create a new field with the correct type, migrate data, and retire the old field.

 

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain – Software Engineer | Turning issues into insights

@Mouktik_B ,

If the solution was helpful , can you please accept the solution and close the thread. That will be much appreciated.

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain – Software Engineer | Turning issues into insights

GlideFather
Tera Patron

Hi @Mouktik_B,

 

This issue was here some time ago. I remember I helped to resolved it -  try to change it to different type - if for example String is not allowed, then select a different one (e.g. Reference), save it, wait and change it to the desired one.

 

Let me know if that helped you

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */