It took me at least two hours to sort out the issue with this one, so I decided to share the blog with you to keep track of what I did
The problem
I need to create a Custom Button and this button will work if Account Object has multiple Records With different Record Types, so on Button click new Account page with predefined Record Type will create so that we don’t need to select Record type first?
The Solution
- Go to Setup
- Click Account
- Click Buttons, Link, and Action
- Click New button or link
Label- New Account Record type
Name- New_Account_Record_Type
Display type- Detail page Button
Behavior- Display in new Window
Content Source- URL
/lightning/o/Account/new?useRecordTypeCheck=1&defaultFieldValues=AccountId={!Account.Id}
This is the formula we need to use to complete this task.
Click Save.
Go to Page Layouts
Account Layout
Mobile & Lightning Actions
Drag and drop the newly created button
Check the appropriate field for our preconfigured Account Name!
Let’s review our work with the formula:
/lightning/o/Account/ – When generating an Account, the “regular” manner, this is a portion of a link. if it’s new, we want to make a new record.
Here the magic begins: useRecordTypeCheck=1. We are stating that in order to display the pick record type window, this “checkbox” needs to be true.
We want the AccountId field to be filled out even before we open the window with the Accounts fields, and by passing the Account Id of the record we are initiating the process, we can do this (from which Account record did we clicked New Account Record type). That’s all.