Salesforce Lightning URL Hacking

Here I have created a custom detail button(New Contact) on Account object with some pre-populated Contact field values from Account record using Lightning URL Hacking.

Go to setup | Object Manager | Account | Buttons, Links, and Actions | Create a new Button

  • Label – New Contact
  • Display Type – Detail Page Button
  • Behavior – Display in new window
  • Content Source – URL

URL Content:

/lightning/o/Contact/new?defaultFieldValues= OwnerId={!Account.OwnerId},AccountId={!Account.Id},MailingStreet={!Account.ShippingStreet},MailingCity={!Account.ShippingCity},MailingState={!Account.ShippingState},MailingPostalCode={!Account.ShippingPostalCode},MailingCountry={!Account.ShippingCountry}

Add this button to Account detail page layout, “Mobile & Lightning Action” section.

Note: This URL Hacking with button doesn’t work in Salesforce1 mobile app.

  • Fathi

    Hi Biswajeet, your blog is very interesting, it is now in my favorites, concerning The Hacking URL (I am not a pure developer), but I have this question to ask you, I have a visulforce page that does the creation account according to the parameters and when I migrate this visualforce page to lightning the controller apex does not copy the information captured from the visualforce page (name and first name) because of the Hacking urls, I have in the controller a function of this type:
    public PageReference CreateContact () {
    string sParam = ‘/ 001 / e? name_lastacc2 =’ + EncodingUtil.urlEncode (oAccount.LastName, ‘UTF-8’) + ‘& nooverride = true’;
    if (oAccount.FirstName! = null)
    sParam + = ‘& name_firstacc2 =’ + EncodingUtil.urlEncode (oAccount.FirstName, ‘UTF-8’);
    if (oAccount.Date_Birth__c! = null)
    {
    string sDate = oAccount.Date_Birth__c.format ();
    // Production
    sParam + = ‘& 00N40000001fqKX =’ + sDate;
    // Sandbox
    // sParam + = ‘& 00NR0000000H4xT =’ + sDate;
    }

    if (oAccount.RecordTypeId! = null && oAccount.RecordTypeId == Label.RECTYPE_ACCOUNT_CAUTION_UNIQUEMENT) {
    sParam + = ‘& RecordType =’ + Label.RECTYPE_ACCOUNT_CAUTION_UNIQUEMENT + ‘& retURL = / 001 / e’;
    } else {
    sParam + = ‘& retURL = / 001 / e’;
    }
    return new PageReference (sParam);
    }
    thank you for your help