Unable to change the field value from String to Reference .

divya1311
Tera Contributor

Hello , 

          I've a field name "assigned_to"  which has type "Reference" , Yesterday I've changed the type from reference to string .But , again  when I try to update the type from string to reference , the following error occurs :

divya1311_0-1668083608241.png

Is there any solution for this ? I need to change the type to reference only . Is there any other ways to do it .?

 

Thanks , 

Divya .

 

5 REPLIES 5

AnubhavRitolia
Mega Sage
Mega Sage

Hi @divya1311 

 

Firstly, this is not recommended to make any changes to OOTB fields. And specially for 'Task' table as this is base table and is extended by 100+ tables so make type change for any field will impact in all the extended table.

 

If you want to revert the changes, Add "Versions" related list in your "Dictionary Entry" form. 

From the Versions, you can sort it by Recorded at and open the old version/last version.

 

AnubhavRitolia_0-1668084825658.png

 

On the Related Link of version, click on "Revert to this Version" and confirm by clicking 'OK' button.

 

AnubhavRitolia_1-1668084907600.png

 

AnubhavRitolia_2-1668084925709.png

 

Verify that Type is reverted back to 'Reference'.

 

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Mohith Devatte
Tera Sage
Tera Sage

hello @divya1311 ,

 

As it is task table which is a global one , try not changing the types of fields , as task table is extended by many child tables which might effect globally.

 

But answer to your question is that You need to clear out the values from the existing records in your table.

The error says you have 336 records in your table where that string field is storing the value .

So clear out the string field value from those 336 records and then try to change it to reference type.It will work.

 

Probably write a background script and update those records string field to empty 

 

Hope this helps 

 

Please mark the answer correct if this helps you 

 

Thanks,

Mohith Devatte

Hi @Mohith Devatte 

                             As I'm new  to servicenow ,I don't where to find those record and how to write the script .So, can u please send me the sample script to clear those 336 records.

 

Thanks ,

Divya.

HELLO @divya1311 ,

SO YOU CAN WRITE LIKE THIS 

var gr = new GlideRecord('task');
gr.addEncodedQuery('your_encoded_query');//build your query to filter out those 336 records;
gr.query();
while(gr.next())
{
gr.your_string_field_backend_name="";
gr.update();
}

Hope this helps 

thanks