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
michaellmichaell 

Picking Record Type in Detail Record Based on Information in Master

I'm sure there's a way I can do this, but I'm trying to figure out if there is a way to set the record type of a detail record based on some information in the master record when I create a detail record in a master-detail relationship.

I know that I can do it when the detail record is *saved* through a workflow rule -- but I'd really like to set the record type when I first hit "new" to create a new detail record on the master's page.

Any ideas?  Suggestions?  Best practices?

Thanks,
Michael
Chris ShadeChris Shade
Hi Michaell,

All the declaritive tools (non-coding tools) such as workflows, process builder, and flows are processed afer the record is saved.

Using an apex trigger you could likely code a solution that is executed before the save.

Some general info about how apex allows you to define before and after save actions: https://developer.salesforce.com/forums/?id=906F0000000AafFIAS

I think your other option would be a custom button, that would also involving coding but likely less.  You'd use that button to create the new detail records.

Chris