Wednesday, March 4, 2020

How to create custom URL button or link in Lightning experience with default field values in salesforce

From Spring'20 onwards you can create the custom URL button with default field values.

you can define the default values while launches the custom button or custom link or custom code to create a new record with prepopulated field values.

Sample Code
/lightning/o/Account/new?defaultFieldValues=
    Name={!URLENCODE(Account.Name)},
    OwnerId={!Account.OwnerId},
    AccountNumber={!Account.AccountNumber},
    NumberOfEmployees=35000,
    CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}

Note: The URLENCODE function works only when creating custom buttons and links. You can’t use it for custom fields.

Demo
Create a new opportunity from the account detail page with populate account values and some of the prepopulated filled values in new opportunity creation form.

Step:1



Step: 2
add the button to the account page layout and click on the new opportunity button.



Output


Note:
  •  The URLENCODE function works only when creating custom buttons and links. You can’t use it for custom fields.
  • URL Hack working only in New Record and not in the Edit forms

Demo Sample:
/lightning/o/Opportunity/new?defaultFieldValues=
    Name={!URLENCODE(Account.Name)},
    OwnerId={!Account.OwnerId},
    Days_To_Close__c=30,
    TotalOpportunityQuantity=2,
    NextStep=Call%20to%20customer,
    Type=New%20Customer



Refereence
https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_general_lex_navigate_to_record_dfv.htm

No comments:

Post a Comment