function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sung Bin KimSung Bin Kim 

Automatically choosing the correct record type based on related object

Hi Everyone! I tried searching within the forum and sadly couldn’t find a new solution to my problem (I found a similar issue from a few years ago but the solution was to build a Oneclick Java button and sadly these aren’t support in Lightning).

I would like to add a new button to my related list that creates a new record that is based on the object record type. For example:

Object A record type A: Button creates a new record for Object B record type A

Object A record type B: Button creates a new record for Object B record type B.

It is important that both record types are available for the user so setting a standard record type is not an option. Any suggestions? 
Pawel BorysPawel Borys
You cannot use JS buttons in lightning but you can create a customized URL button

For example
Will open a new record window with the specified record type already set. You can even store the id in a custom setting if you don't want to hardcode it in the button.

You can read more about "URL hacking" here (