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
sajitha Joseph 11sajitha Joseph 11 

Country state picklist enabling

HI,

I have enabled State and Country picklist in my Org and the scan identidied a number of Apex classes that needs code fixes.

I have an apex classs that was querying user object and it was querying state and country fields. As a result of the scan this class was picked up in the result and as a fix I changed ths state and country to say stateCode and countryCode hoping that this would take this class out of the scan results list.

But even after this change this class is still showing up in the scan results. 

Is it ok to ignore this?. Please comment or let me know if you need further information

Original code
user = [SELECT id, email, username, usertype, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title, street, city, PostalCode, state, country, localesidkey, mobilephone, extension, fax, contact.email FROM User WHERE id = :UserInfo.getUserId()];

Changed Code
user = [SELECT id, email, username, usertype, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title, street, city, PostalCode, stateCode, countryCode, localesidkey, mobilephone, extension, fax, contact.email FROM User WHERE id = :UserInfo.getUserId()];
AnkaiahAnkaiah (Salesforce Developers) 
Hi Sajitha,

Have you replaced all the apex classes with stateCode, countryCode fields then fine.

THanks!!
sajitha Joseph 11sajitha Joseph 11
But then why is the apex class still showing up in the scan result?. 
Shri RajShri Raj
It is possible that the Apex class you modified still contains references to the old field names "state" and "country" in other parts of the code, such as in variables or method calls. This would cause the class to still be flagged by the scan. It would be best to thoroughly check the class and any related classes or triggers to ensure that all references to the old field names have been changed to the new field names "stateCode" and "countryCode". If you are unable to resolve the issue, it would be best to reach out to Salesforce Support for further assistance.
Ivyevelyn albertIvyevelyn albert
Enable and Disable State and Country/Territory Picklists
1-From Setup, enter State and Country/Territory Picklists in the Quick Find box, then select State and Country/Territory Picklists.
2-On the State and Country/Territory Picklists setup page, click Enable Picklists for Address Fields to turn on the picklists.
sajitha Joseph 11sajitha Joseph 11
Hi Thank you for response. My question was regarding the fix that was already done to apex classes that acceses the relevant fields as described earlier in my chain and yet the apex class still shows up in the scan results. The link to scan results was attached. Please check the apex classes to see if you see any issues or if they are ok. no errors are seen. Thanks Sajitha