You need to sign in to do that
Don't have an account?

Issue with getSobjectType - Save error: Comparison arguments must be compatible types
Having trouble understanding why my code is giving me the error below. I have a feeling it's obvious, but I'm baffled nonetheless. Trying to use getsobjectype in my if statement to verify that the lead owner is a user (i.e. to exclude queues).
Save error: Comparison arguments must be compatible types: SOBJECT:Lead, Id
Trouble line of code:
if(l.Lead_Stage__c.contains('Engaged') && l.Status.contains('Team Contribution') && userMap.get(l.OwnerId).Profile.Name.contains('LDR')
&& l.OwnerId.getSobjectType()==user.sObjectType && oldMap.get(l.OwnerId) == LDRmanagerQueue.Id)
Rest of that section of code:
public static void updateLDRlead(List<Lead> newList, Map<Id,Lead> oldMap){ List<Lead> leadsToBeProcess = new List<Lead>(); for(Lead l: newList){ Lead oldL = oldMap.get(l.Id); leadOwnerIds.add(l.ownerId); leadOwnerIds.add(oldL.ownerId); if(l.Meets_LDR_Process_Criteria__c == true && l.Remove_from_LDR_Program__c == false){ //Add to list of leads currently in the LDR Program leadsToBeProcess.add(l); //Set Record Type l.RecordTypeId = LDRrecord.Id; //Set Status to Nurture when entering the program if(oldL.Meets_LDR_Process_Criteria__c == false && l.Meets_LDR_Process_Criteria__c == true){ l.Status = 'Nurture'; } //Default Inquiry/Nuture to Lead Development Queue if(l.Lead_Stage__c == 'Inquiry' && l.Status == 'Nurture'){ l.OwnerId = LDRmanagerQueue.Id; } //Stage is Engaged, Status is Team Contribution, and Owner changes LDR Manager Queue --> LDR if(l.Lead_Stage__c.contains('Engaged') && l.Status.contains('Team Contribution') && userMap.get(l.OwnerId).Profile.Name.contains('LDR') && l.OwnerId.getSobjectType()==user.sObjectType && oldMap.get(l.OwnerId) == LDRmanagerQueue.Id){ } } } }
Thanks in advance for any assistance!
I'd image that the last part gives the error, oldmap.get() will return a Lead as its defined as Map<id,lead> which you can't compare to an Id. (and I'm not really sure that this is really what you want as ownerId isn't going to be a lead anwyay.
All Answers
I'd image that the last part gives the error, oldmap.get() will return a Lead as its defined as Map<id,lead> which you can't compare to an Id. (and I'm not really sure that this is really what you want as ownerId isn't going to be a lead anwyay.
But I am trying to compare the current/new lead ownerId to make sure it is a user and not a queue.