• DaveT.ax1572
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

I am using a trigger to fire on my web to lead form from a specific leadsource to create a contact.  Is there a way for it to not create an account but add the contact to and existing account?  here is my code.  what I am thinking is that I would create an account trigger to fire on the leadsource and add the contact to the account correct??

 

here is the lead trigger:

trigger KYR_LeadConvert on Lead (after insert,after update) {
List<String> LeadNames = new List<String>{};
for(Lead myLead: Trigger.new){
 if((myLead.isconverted==false) && (myLead.LeadSource == 'youknowit')) {
Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(myLead.id);
        lc.setopportunityName(myLead.Refersite__c);
        lc.convertedStatus = 'Qualified';
        
        //Database.ConvertLead(lc,true);
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        System.assert(lcr.isSuccess());
        }
        }
}

 

thank you for the help;)

I am using a trigger to fire on my web to lead form from a specific leadsource to create a contact.  Is there a way for it to not create an account but add the contact to and existing account?  here is my code.  what I am thinking is that I would create an account trigger to fire on the leadsource and add the contact to the account correct??

 

here is the lead trigger:

trigger KYR_LeadConvert on Lead (after insert,after update) {
List<String> LeadNames = new List<String>{};
for(Lead myLead: Trigger.new){
 if((myLead.isconverted==false) && (myLead.LeadSource == 'youknowit')) {
Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(myLead.id);
        lc.setopportunityName(myLead.Refersite__c);
        lc.convertedStatus = 'Qualified';
        
        //Database.ConvertLead(lc,true);
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        System.assert(lcr.isSuccess());
        }
        }
}

 

thank you for the help;)

I have a Workflow rule that creates a Task each time a specific type of Lead is created.  I have a custom field in this Task that needs to be populated upon creation but I cannot accomplish this with the Workflow so I am creating a trigger. 

 

I get the following error when I save the trigger

 

Error: Compile Error: unexpected token: '}' at line 5 column 12

 

Here is the trigger

 

trigger PubProductUpdate on Task (before insert){

    for (Task PU : Trigger.new){
        if (PU.RecordTypeId = '012U0000000Z6qBIAS' && PU.Subject = 'Pitch Networks' && PU.Pub_Products__c = null)
            }
    {
    
    PU.Pub_Products__c = 'Pub Opening Pitch';
    }
}

 

I am new to Apex Triggers and not sure where my select criteria goes wrong. 

 

Thanks.