Unable to change the field value from String to Reference .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 04:42 AM
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 :
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 04:49 AM - edited 11-10-2022 04:56 AM
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.
On the Related Link of version, click on "Revert to this Version" and confirm by clicking 'OK' button.
Verify that Type is reverted back to 'Reference'.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 04:52 AM - edited 11-10-2022 04:54 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 09:30 PM - edited 11-15-2022 04:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 04:59 AM
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