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
CoderCoder 

Getting Invalid Identifier error

public class demods { public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); for(Streams__c p:[Select p1.Streams__c From Application__c p1])<-Error Displays Here { Application__c.add(p1.Streams__c); } List<String> Streams__c = new List<String>(Streams__c); for(integer i=0; i<Streams__c.size(); i++){ options.add(new SelectOption(Streams__c[i],Streams__c[i])); } options.add(new SelectOption('All Lunch Choices','All Lunch Choices')); return options; } }

Error: Compile Error: Invalid identifier: Streams__c

 

Hi

 

 I' m trying a code get the values from one field in an object and trying to display the unique values but whenever i saved it i'm getting the error message INVALID IDENTIFIER.Can anyone help me to solve this problem

soofsoof

Two things to check:

 

  1. Does an S-Object named Streams__c exist?  The loop on the erroneous line is creating a variable of type Streams__c.
  2. Your query on the erroneous line is being run on the Application__c custom object, but you're creating a variable of type Streams__c, which is incorrect.
The next issue that I see in this code is that you're doing Application__c.add(p1.Streams__c); but Application__c is NOT a list, and p1 is NOT a variable/object.
 
-soof 

 

sandeep@Salesforcesandeep@Salesforce

Some time this error comes if you are using any variable name with '__' like 

 

public static String START__END_VALIDATION_MSG = 'End date  may not be less than Start date' ;

 

Here is consider it as an API name so fire error.