This one kept me occupied for at least 2 hours until I figure out what was the problem, so in order to remember what I have done and hopefully help someone not to loose any time, I decided to share this scenario with you.
THE PROBLEM
So, the task is the following: we have couple of opportunity record types and I want to be able to create a new opportunity, choose the record type AND I want to be able to do this from an Account object page AND to have the Account ID preselected on the newly created opportunity.
When I click: Opportunities Tab
New button
I got the record type selection window, so far so good.
![](https://static.wixstatic.com/media/4620a7_e78eb5b994aa4392a490dd6d8051451f~mv2.png/v1/fill/w_980,h_428,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/4620a7_e78eb5b994aa4392a490dd6d8051451f~mv2.png)
When I try to add a button on the Account page, I get this problem
If I try to add it as a New Action:
Action Type - Create a Record
Target Opportunity - Opportunity
Record Type - Uhhhh, I want all please!
![](https://static.wixstatic.com/media/4620a7_da21899ad6db4bfc95c1377d8a0b3c30~mv2.png/v1/fill/w_980,h_478,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/4620a7_da21899ad6db4bfc95c1377d8a0b3c30~mv2.png)
I am not able to choose all of the record types and I did not want to use any Visualforce / LWC solution. So,
THE SOLUTION
On the Account object ( in my case ):
Buttons, Links, and Actions
New Button or Link
Label - New Opportunity Type
Display Type - Detail Page Button
In the formula window ( now comes the fun part ), add this line:
/lightning/o/Opportunity/new?useRecordTypeCheck=1&defaultFieldValues=AccountId={!Account.Id}
![](https://static.wixstatic.com/media/4620a7_201094c085624389b73ec8971a71cadd~mv2.png/v1/fill/w_980,h_453,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/4620a7_201094c085624389b73ec8971a71cadd~mv2.png)
SAVE
Go to Page Layouts
Account Layout
Mobile & Lightning Actions
Drag and drop the newly created button
![](https://static.wixstatic.com/media/4620a7_44eacbe354ec4af9be756ce88318e227~mv2.png/v1/fill/w_980,h_219,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/4620a7_44eacbe354ec4af9be756ce88318e227~mv2.png)
SAVE
The moment of truth! Go to Account, click a random Account record and check the button we just created:
![](https://static.wixstatic.com/media/4620a7_fc5bef04937e4cbbaeff958b0447493d~mv2.png/v1/fill/w_980,h_264,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/4620a7_fc5bef04937e4cbbaeff958b0447493d~mv2.png)
CLICK IT! CLICK IT! CLICK IT! Sorry, can't help it, I am excited:
![](https://static.wixstatic.com/media/4620a7_c43da77e1f2a44be8edb0cd347c12790~mv2.png/v1/fill/w_980,h_364,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/4620a7_c43da77e1f2a44be8edb0cd347c12790~mv2.png)
YEAAAAAAAH!!!! We can choose the opportunity record type! Click Next:
![](https://static.wixstatic.com/media/4620a7_6bf3fbb109cb43458f9aa5db22c62333~mv2.png/v1/fill/w_980,h_463,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/4620a7_6bf3fbb109cb43458f9aa5db22c62333~mv2.png)
Check our predefined Account Name in the proper field! Cool, huh?
Let's check what we did in the formula:
/lightning/o/Opportunity/ - this is part of a link, when creating an Opportunity, the "normal" way
new? - we want to create new record
useRecordTypeCheck=1 - here is where the magic starts. We are saying that this "checkbox" must be true in order to see the choose record type window
defaultFieldValues=AccountId={!Account.Id} - we want the AccountId field to be populated even before we open the window with the opportunity fields and we are passing the Account Id of the record we are triggering the operation ( from which Account record did we clicked New Opportunity Type button ).
That's it, hope it helps!!! :)
NOTE: link to ideas.salesforce:
Hello,
Thanks so much for the above formula. I am trying to use this in a custom "New Event" scenario to select a record type associated with a custom page layout. My hurdle is getting the new event to relate to the account. For whatever reason the Related To Account field will not prefill with the account that the user is in, etc. This is what I have:
/lightning/o/Event/new?useRecordTypeCheck=1&defaultFieldValues=AccountId={!Account.Id}, WhatId={!Account.Id}
Thanks in advance for your help. :)
Hi, I'm trying to default more field values but I'm not sure how to format the formula. This is what I have:
/lightning/o/Case/new?useRecordTypeCheck=1&defaultFieldValues=Order__c={!Order.Id}
I'm creating a case from the Order and I want to default the Order field with the Order which is working above, but if I add more default values it won't work.
Here's what I tried:
/lightning/o/Case/new?useRecordTypeCheck=1&defaultFieldValues=Order__c={!Order.Id}&defaultFieldValues=ContactId={!Order.Patient_Contact_ID__c}
I wish I could get this to work from the Account to create an opportunity but I cannot get the Opportunity button to show in Lightning. I add it to the page layout but it does not display.