+ Start a Discussion
Jay reddyJay reddy 

Adding SCHEMA.OBJECTNAME in the code. Apex Compiler - Product & Service Notification

Hi all,

I have an email about Code changes required for Apex compiler. In that, one of the scenario is binding SCHEMA to objectname in the code.

Should I have to add/ modify map<Id, OpportunityLineItem> TO map<Id, Schema.OpportunityLineItem> in all codes??

I appreciate your help.



User-added image
Thanks
GR
Best Answer chosen by Jay reddy
jigarshahjigarshah
Yes, check for Apex classes with the same name as the SObject Names and rename those classes so that their names do not collide and the Apex Compiler is able to resolve calls to them.

Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.

All Answers

jigarshahjigarshah
Girish,

It seems based on the snapshot, that, there could be a possibility that a custom Apex class exists in your org, with exactly the same name as one of the standard SobjectType classes in your Salesforce org.

Owing to this, the Apex compiler is unable to distinguish and resolve the call, performed to the respective class i.e. Contact. Hence, to enable the Apex compiler resolve the call and associate it to the respective Sobjecttype,due to ambiguous names, the compiler expects providing a fully qualified name for that respective class by associating a namespace i.e Schema in this case, before the respective class name.

A simpler approach would be to identify if there exists a custom Apex class with the same name as that of a standard Sobjecttype on your Salesforce org and modify the name to make it unique. It is always recommended that the reserved Apex keywords including SObject names should not be used for naming custom types and variables. Hope that helps.

How and when did you encounter this message?

Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
Jay reddyJay reddy
@jigarshah

Thank you so much for your help and information. So in cut short, did you mean to check for classes with same names as SObject Names? Sorry, just need a bit of more clarification.

To answer your question, I've got an email from Salesforce regarding "Code changes required for Apex compiler - Product & Service Notification"

Thanks,
GR
jigarshahjigarshah
Yes, check for Apex classes with the same name as the SObject Names and rename those classes so that their names do not collide and the Apex Compiler is able to resolve calls to them.

Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
This was selected as the best answer
jigarshahjigarshah
Yes.