Activity Forums Salesforce® Discussions Define error: "Initial term of field expression must be a concrete SObject: LIST " in Salesforce

  • shradha jain

    Member
    September 6, 2018 at 5:26 am

    Hi Anjali,

    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[0].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;
    TrsfrMgr.add(a);
    }

    Hope it helps.

     

     

     

  • Parul

    Member
    September 24, 2018 at 1:03 am

    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 .

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos