- July 2, 2018 at 11:27 am #29586Anjali #7
Define error: “Initial term of field expression must be a concrete SObject: LIST
” in Salesforce
What kind of error is “Initial term of field expression must be a concrete SObject: LIST<User> “September 6, 2018 at 5:26 am #33177shradha jain #14
The reason for this kind of error may be comparison of list with single sobject because list is a collection of data ,you can’t compare with it single sobject .
For example, in the code below we query the set of users [into list variable user}for which ManagerId with a new Id are updated and then adding it to TrsfrMgr list. The assignment to update manager Id is not working because of the difference in the data type. When we retrieve using Name, we are defining ToMgrID as a List<User>. Whereas in the suggestion by codeinprogress, the ToMgrID was defined with data type as Id. In this code ToMgrID.Id would have worked as it would use the first record from the list.
List<User> FromMgrId ,ToMgrID ;
ToMgrID = [select Id from User where name=: ToMgr] ;
for (User a : user)
system.debug(‘OLDMgrId’ + a.ManagerId);
a.ManagerId = (ID) ToMgrID.Id;
Hope it helps.September 24, 2018 at 1:03 am #38127
Please Register to reply to this topic. /