You need to sign in to do that
Don't have an account?
Compile Error: Initial term of field expression must be a concrete SObject
Hi All,
I am new to salesforce, currenlty i facing an compiler error : Initial term of field expression must be a concrete SObject at bolded line.
I'm not able to understand why i getting this error. Since i need to add KEY1__C value to the list.
kindly let me know if my usage of the code is wrong.
List<String> pereTechniqueParams = new List<String>();
for (String key1: [SELECT KEY1__c FROM Parameters__c WHERE TYPE__c = 'PERE_TECHNIQUE']){
pereTechniqueParams.add(key1.KEY1__c); // Compile Error: Initial term of field expression must be a concrete SObject: String at line 30 column 41
}
Hi,
the SOQL query will return a list of sObjects, in this case a list of Parameters__c, so key1 is of type Parameter__c.
List<String> pereTechniqueParams = new List<String>();
for (Parameters__c key1: [SELECT KEY1__c FROM Parameters__c WHERE TYPE__c = 'PERE_TECHNIQUE']){
pereTechniqueParams.add(key1.KEY1__c);
}
Thanks,
James.
All Answers
Hi,
the SOQL query will return a list of sObjects, in this case a list of Parameters__c, so key1 is of type Parameter__c.
List<String> pereTechniqueParams = new List<String>();
for (Parameters__c key1: [SELECT KEY1__c FROM Parameters__c WHERE TYPE__c = 'PERE_TECHNIQUE']){
pereTechniqueParams.add(key1.KEY1__c);
}
Thanks,
James.