+ Start a Discussion
RajivRajiv 

Strange error opportunity Id does not exist in Sandbox

Could anyone help me on this, I am getting very strange error in  the Sandbox.

For example if I am trying to write below code an error appears  Variable  does not exist :Id

 

trigger demo on Opportunity (after insert) {

List<Id> oppIds = new List<Id>();
    for(Opportunity opp : Trigger.new){

        oppIds.add(opp.Id);
    }

}

 

I don't understand why this strange error is coming that Id does not exist.

Id is a standard  field of opportunity, could any one help me to resolve this issue or anyone knows why this error is coming. 

It will be really appreciated. Thanks !!

 

Regards,

Rajiv Roy

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma

Rajiv, Ensure your org is not having any class with Name as Opportunity. If so, delete/rename it and try again.

All Answers

SeAlVaSeAlVa

One suggestion:

trigger demo on Opportunity (after insert){
  List<Id> oppIds = new List<Id>(Trigger.newMap.keySet());
}

 I believe that you have more code below this, if you keep having problems, it is better to quote the exact error message.

 

Hope this helps,

regards

RajivRajiv

Thanks for the reply Sealva. Actually I have written only this portion of code and tried to save the code but got this error that "Id"  does not exist.

SeAlVaSeAlVa

I have updated the code, it should work, at least it was saved on one of my sandbox.

 

Let me know what happens

Rahul SharmaRahul Sharma

Rajiv, Ensure your org is not having any class with Name as Opportunity. If so, delete/rename it and try again.

This was selected as the best answer
RajivRajiv

Thank you so much!! It's resolved now. Thanks a lot!!