You are here:
Custom Button Example: Record Create Page with Default Field Values
Construct custom buttons and links that pass default field values to a record create page. This feature applies to Lightning Experience in all editions. This feature doesn’t apply to Lightning Out, Experience Builder sites, or the Salesforce mobile app.
-
Define a custom button or link, and encode any field that is read from a record and
contains special characters, like commas.
Use this sample formula.
/lightning/o/Account/new?defaultFieldValues= Name={!URLENCODE(Account.Name)}, OwnerId={!Account.OwnerId}, AccountNumber={!URLENCODE(Account.AccountNumber)}, NumberOfEmployees=35000, CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}Important TheURLENCODEfunction works only when creating custom buttons and links. You can’t use it for custom fields. TheTEXTfunction is supported for custom number fields, but it returns only the numbers without any separators, like commas. - Add the button or link to the appropriate page layout.
RecordTypeId to defaultFieldValues isn’t yet supported. The recordTypeId influences routing behavior, layout assignment,
and page assignment, so you can see unexpected results if you try to use it.