function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Saju NathSaju Nath 

Trying to Change the Datatype of the field from text to picklist

Hi All,

While trying to change the data type of the field from text to picklist, i am facing the issue as show below

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Cannot change field type of a custom field referenced in Apex class or trigger: <a href="/01pG0000002ttC6">GAQReport_TestClass</a>". 

Can you please suggest me how to over come this issue or any other alternative way to fix it.

Thanks in Advance.
bob_buzzardbob_buzzard
You have to comment out the use of that field in your Apex, then you can change the field type, and then undo the commenting. There's no other way around it I'm afraid.
Saju NathSaju Nath
Thanks Bob.

I am trying to fetch all the references which are linked with the field 'PLU'. For that i am trying to write the query, so can you please help me, how to fetch the references for a particular field in query level. Which i can execute it in Salesforce Developer console.
AshlekhAshlekh
Hi,

1) Please take a metadata of your porject in Eclipse and find the reference of that field. OR
2) Try to delete this field on object level than it gives  you an exception and tell you that this field is being used these places.

-Thanks
Ashlekh Gera
Sumit Kumar Singh 9Sumit Kumar Singh 9
First you should fetch your project to Eclipse and then, try to find the paticular field let's say "PLU__c" by hitting "Ctrl+H". It will list all the Apex classes/Triggers etc whereever the field is being referened. Try to comment it out and save it back, then and only then you will be able to change the datatype of a particular field.

Thanks,
sumit kumar singh
Saju NathSaju Nath
Thanks Ashlekh,

As you mentioned in the post like Try to delete this field on object level, So, can you please let me know what are the steps need to follow to do the deletion in object level.