0

I am trying to figure a way to create a record in a custom object whenever a lead is converted as certain fields are populated. The object in mind is something I call "License Agreement." Would this be possible through a workflow or a trigger, etc.

Hope it helps.

3

Not possible using a workflow, probably possible using process builder - that's not my domain so I'm not 100% sure. However, I do know that if you used process builder, it wouldn't be bulkified.

If you want it bulkified (i.e. if you want the process to be able to handle batches of hundreds of records or more, such as during a data load or a batch process), you can use a trigger on Lead. Post more detailed requirements and I can help you through the Apex logic.

trigger CreateCustomRecs on Lead (before update) {
    List<License_Agreement__c> recordsToInsert = new List<License_Agreement__c>();
    for (Lead l : Trigger.new) {
        if (l.IsConverted) {
            License_Agreement__c la = new License_Agreement__c();
            // populate new record fields here
            recordsToInsert.add(la);
        }
    }
    insert recordsToInsert;
}
| improve this answer | |
  • Did the trick. But I also found workflows to be useful and expedient to get what I wanted. – Medhanie Habte Aug 12 '15 at 14:55
  • Could you please elaborate on how you used a workflow to achieve this? @MedhanieHabte – Brian Mansfield Aug 12 '15 at 14:58
  • 1
    I created some fields (like a checkbox) to autopopulate based on lead status so when a lead is converted, the license agreement record is created with the corresponding data. Much of this was completed through Lightning Process Builder, where when a status is marked, it then ports over to the contact upon conversion, and creates the record. The key thing here is the checkbox field auto-populating. It may not involve writing code, but eh, whatever gets it done. – Medhanie Habte Aug 12 '15 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.