• Sameer Vits
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 16
    Replies
We have a requirement where we want to check if contact exists using email address custom field. If contact exists then we just want to update incoming information. If contact doesn't exists then it should create a new contact. Also, is apex a better solution or workflows?
Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            Leadconvert.setLeadId(LeadIds[0]);
            lead l= [SELECT Id, email FROM Lead WHERE id=:LeadIds[0]];
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            contact[] clist=[select id,name,session__c from contact where email=:l.email limit 1 ];
            
            if(clist.size()>0){
                contact c=clist[0];
                c.session__c='PUT_THE_VALUE_YOU_WANT_TO_UPDATE_THE_FIELD_WITH'; //Make sure you are inserting value according to field type.
                update c;
            }
            else{    
                Leadconvert.setConvertedStatus(Leads.MasterLabel);
                Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion 
                Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
                System.assert(Leadconverts.isSuccess());
           }
   }
}
The session value comes from web to lead form depending on person signing up. It's a picklist. The values are dates as mentioned - May 24; 2 PM - 4 PM, June 28; 9 AM - 12 PM, May 24; 10 AM -12 PM, June 28; 4:30 PM - 7:30 PM, July 26; 9 AM - 12 PM, July 26; 4:30 PM - 7:30 PM. 

How can I pass these values into this trigger code for c.session__c ?
 
I have a trigger autoconverting leads into Contact when someone submits the web to lead form. I want to update 'session' field under Contact, if Contact (converted lead) already exists. If we can check this using email address. I am new with Apex and need help with writing the code.  
In Pardot, automation rule doesn't email duplicate emails. It says 'not applied: duplicate email'? Is there a way to change it to where it can still send email to duplicate emails too.
I have a custom date field. I want the date field use a datepicker instead of text and still return value to Salesforce.
I have 2 fields, one is custom text field A and second is PAP lookup field. Both fields are under Contacts. Is there a way to copy text from text field 'A' to lookup field 'PAP'? PAP lookup field is looking up to Account Name.
We have a requirement where we want to check if contact exists using email address custom field. If contact exists then we just want to update incoming information. If contact doesn't exists then it should create a new contact. Also, is apex a better solution or workflows?
Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            Leadconvert.setLeadId(LeadIds[0]);
            lead l= [SELECT Id, email FROM Lead WHERE id=:LeadIds[0]];
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            contact[] clist=[select id,name,session__c from contact where email=:l.email limit 1 ];
            
            if(clist.size()>0){
                contact c=clist[0];
                c.session__c='PUT_THE_VALUE_YOU_WANT_TO_UPDATE_THE_FIELD_WITH'; //Make sure you are inserting value according to field type.
                update c;
            }
            else{    
                Leadconvert.setConvertedStatus(Leads.MasterLabel);
                Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion 
                Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
                System.assert(Leadconverts.isSuccess());
           }
   }
}
The session value comes from web to lead form depending on person signing up. It's a picklist. The values are dates as mentioned - May 24; 2 PM - 4 PM, June 28; 9 AM - 12 PM, May 24; 10 AM -12 PM, June 28; 4:30 PM - 7:30 PM, July 26; 9 AM - 12 PM, July 26; 4:30 PM - 7:30 PM. 

How can I pass these values into this trigger code for c.session__c ?
 
I have a trigger autoconverting leads into Contact when someone submits the web to lead form. I want to update 'session' field under Contact, if Contact (converted lead) already exists. If we can check this using email address. I am new with Apex and need help with writing the code.  
I have 2 fields, one is custom text field A and second is PAP lookup field. Both fields are under Contacts. Is there a way to copy text from text field 'A' to lookup field 'PAP'? PAP lookup field is looking up to Account Name.