+ Start a Discussion
Abhishek_NewAbhishek_New 

Save error: Initial term of field expression must be a concrete SObject: LIST<position__c>

I tried to write my first apex code....

 

public with sharing class HelloWorldPositionClass

{

public static void HelloWorld(position__c[] positions)

{

for(position__c[] p:positions)

{

if (p.Hello__c = null || p.Hello__c != 'world')

p.Hello__c ='World';-->Error*

}

}

}

 

Iam getting the error while saving--Save error: Initial term of field expression must be a concrete SObject: LIST<position__c>  what does it mean ? how to solve?

Best Answer chosen by Admin (Salesforce Developers) 
SFDC-SDSFDC-SD
Moving 'World' into a list is not allowed. Thats the reason you got that error.
Use the below code, that should work.
public with sharing class HelloWorldPositionClass {
    public static void HelloWorld(position__c[] positions) {
	for(position__c p :positions)
	{
            if (p.Hello__c = null || p.Hello__c != 'world')
		p.Hello__c ='World';
	}
    }
}

 

 

All Answers

SFDC-SDSFDC-SD
Moving 'World' into a list is not allowed. Thats the reason you got that error.
Use the below code, that should work.
public with sharing class HelloWorldPositionClass {
    public static void HelloWorld(position__c[] positions) {
	for(position__c p :positions)
	{
            if (p.Hello__c = null || p.Hello__c != 'world')
		p.Hello__c ='World';
	}
    }
}

 

 

This was selected as the best answer
Abhishek_NewAbhishek_New
Thanks ?Regards, Abhishek Dey +919036471705 mailto: abhishekdey@y7mail.com? ----------------------------------------------- please consider the environment... print this?only if you really need to