When Admin met Developer - Mystery of Lead's Company Field!

Our #AwesomeAdmin Adam is working on a project and received a requirement from the Almighty Client. The requirement was to have a Lookup field on Lead to account instead of the text field of Company! That sounds easy, right?

But what about the company field then, that is Always on Layout. Now Adam was clueless, that what to do with this Company field because this field is used during conversion as well and the business doesn't require Individual Contacts.

So over lunch with Debbie (our pro developer from the story), he was discussing the crazy requirement with her. And she told him that, there is a workaround for this. And this is her plan!

  1. To create a new lookup field to account. (Well that was obvious😎)

  2. Put the Company field at the end of the layout.

  3. Override the new button on lead with the aura component that she will give to adam. (This component is going to pass a default value to Company field)

  4. Use the Process Builder/ Workflow to update the Company field with Account__r.Name. (So that at the time of conversion of lead, it will have the Account Name).

The component looks like this:

leadNewButtonComponent.cmp

<aura:component implements="lightning:actionOverride" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/></aura:component>
leadNewButtonComponentController.js
({
    doInit : function(component, event, helper) {
        var createAcountContactEvent = $A.get("e.force:createRecord");
        createAcountContactEvent.setParams({
            "entityApiName": "Lead",
            "defaultFieldValues": {
                'Company' : 'Temprory Data' //This will pass default      
            }
        });
        createAcountContactEvent.fire();
    }
})

Then override the New button on Lead with the custom component.

Edit the page layout of lead, and put the company field at the last! Something like this.

Now create the Process builder and push Account__r.Name to the company field!

So that's how the magic happens when Admin and Developer come together. Let me know, how you handle such requirements and add a comment below😇

Check these previous discussions of Adam and Debbies - When Admin Met Developer .

330 views0 comments

Recent Posts

See All