• Harry G
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
I have created a trigger(after update) on Lead which will fire on status change and create a contact and custom object record.

Issue is that trigger is working but creating around 7 records of contact and custom object , i am not able to debug this , any help would be helpful.

Trigger:

Trigger CreateContact on Lead (after insert, after Update) {
    if(Trigger.isInsert) {
        LeadTriggerHandler.createContact(Trigger.new);
    }
        if(Trigger.isUpdate) {
        LeadTriggerHandler.createContact(Trigger.new);
    }
}

Class:

public class LeadTriggerHandler {
    public static void createContact(List<Lead> leads) {
        List<Application__c> app = new List<Application__c>();
        List<Contact> contact = new List<Contact>();
           for(Lead acc : leads){
            if(acc.Status=='Interviewed'){
            Contact con = new Contact(LastName = acc.lastname,
                                     FirstName= acc.FirstName,
                                     RecordTypeId='someid');
            contact.add(con);
        }
        insert contact;
        }
        for(Lead acc : leads){
            if(acc.Status=='Interviewed'){
            Application__c a = new Application__c(Name = acc.Lead_Program_Name__c,
                                                 Program__c= acc.Program__c,
                                                 Last_Name__c= acc.LastName,
                                                 First_Name__c= acc.FirstName,
                                                 Program_Session__c= acc.Program_Session__c);
            app.add(a);
        }
        insert app;
        }
    }
}

 
Hi ,

I have a use case wherein i need to update a picklist field of an object based on the changes done to another picklist field on the same obejct , please let us know if this can be done through process builder , if yes how can this be achieved??
  • September 21, 2018
  • Like
  • 0
I have created a trigger(after update) on Lead which will fire on status change and create a contact and custom object record.

Issue is that trigger is working but creating around 7 records of contact and custom object , i am not able to debug this , any help would be helpful.

Trigger:

Trigger CreateContact on Lead (after insert, after Update) {
    if(Trigger.isInsert) {
        LeadTriggerHandler.createContact(Trigger.new);
    }
        if(Trigger.isUpdate) {
        LeadTriggerHandler.createContact(Trigger.new);
    }
}

Class:

public class LeadTriggerHandler {
    public static void createContact(List<Lead> leads) {
        List<Application__c> app = new List<Application__c>();
        List<Contact> contact = new List<Contact>();
           for(Lead acc : leads){
            if(acc.Status=='Interviewed'){
            Contact con = new Contact(LastName = acc.lastname,
                                     FirstName= acc.FirstName,
                                     RecordTypeId='someid');
            contact.add(con);
        }
        insert contact;
        }
        for(Lead acc : leads){
            if(acc.Status=='Interviewed'){
            Application__c a = new Application__c(Name = acc.Lead_Program_Name__c,
                                                 Program__c= acc.Program__c,
                                                 Last_Name__c= acc.LastName,
                                                 First_Name__c= acc.FirstName,
                                                 Program_Session__c= acc.Program_Session__c);
            app.add(a);
        }
        insert app;
        }
    }
}

 
Hi ,

I have a use case wherein i need to update a picklist field of an object based on the changes done to another picklist field on the same obejct , please let us know if this can be done through process builder , if yes how can this be achieved??
  • September 21, 2018
  • Like
  • 0
A Create a Record action for the Closed Won criteria node isn’t properly configured. Make sure that it creates a task and uses the same field settings as the ‘Follow up on new contract’ task action. Make sure that Due Date Only is set by using a formula.
User-added image

Hep me for this Problem!