Dictionary Field change type from Date to Date/Time

felipe_barbosa
ServiceNow Employee
ServiceNow Employee

Hi everyone,

 

Do you people know about a workaround to change a field type from Date to Date/Time? If I try directly in the dictionary personalization, it will block the change saying that can't convert from date to date/time, but I don't want to create a new field as the change impact on all the code that works around this field would be terrible to track and fix. All the source information that goes to this date field are already date/time so I believe that simply changing the field type is the less hurtfull change.

 

Hope to hear from you soon!

 

Thanks and regards,

 

Felipe

11 REPLIES 11

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,



This is the business rule "Validate type change"which will prevent the change of type for the field..


Make sure to make the BR active as true once you are done with the changes to the field.



Let me know if you have any questions.



Thanks


Pradeep Sharma


Mark Stanger
Giga Sage

This isn't possible because the underlying data types at the database level are not the same.   It won't matter if you bypass the checks ServiceNow has in place.   Your only option if you need a different field type is to create a new field with that type.


Hi Mark, and hi to you too Pradeep, I understand that this is a change that is not allowed by the OOTB system, but what if I disable the BR Pradeep mentioned, "Validate type change", then proceed with the change in the field type, enable again the BR and run a script that would take the value in the field, transform it on a date/time information with GlideDateTime variable and then save this information back to the field, would it work alright?



Just stressing my options because, as I mentioned, to create a new field at this stage unfortunatelly would bring a lot of pain for us developers.


That's what I'm saying, it will not work.   Changes to the dictionary don't change the underlying database and date vs datetime is different at that level.   It's the same as trying to change an integer-based field to a string.   They're not compatible at the DB level so you can't convert between the two.