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
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