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
JoannaAtMaritzJoannaAtMaritz 

Apex Trigger

I am trying to write simple trigger that needs some kind of not logic.  Can someone please give me some examples.  This is what I am trying to write

 


trigger SetLeadOwner on Lead (before insert, before update) {
for (Lead TempLead: System.Trigger.new)
if (TempLead.Owner not like('%Queue%'))
    {     
 TempLead.LeadOwner__c = TempLead.OwnerId;
    }
}

gotherthanthougotherthanthou

trigger SetLeadOwner on Lead (before insert, before update) { for (Lead TempLead: System.Trigger.new) if (TempLead.Owner.contains('Queue') == false) TempLead.LeadOwner__c = TempLead.OwnerId; }

 

This is aircode
JoannaAtMaritzJoannaAtMaritz

trigger SetLeadOwner on Lead (before insert, before update)
{
    for (Lead TempLead: System.Trigger.new)
    if (TempLead.Owner.contains('Queue') == false)
        TempLead.LeadOwner__c = TempLead.OwnerId;

 

after execute I get the following error message

 

Error: Compile Error: Method does not exist or incorrect signature: [SOBJECT:Name].contains(String) at line 3 column 5 

 

 

cloudcodercloudcoder

Try:

 

TempLead.Owner.Name.contains('Queue');

 

Owner on the Lead Object is a lookup to User.