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
AbAb 

Master detail relation | Record types | Force specific record type for child based on parent record type

Hello,

#I have two objects.
> Standard object (contact) (Master)
> Custom object (cust__c) (Detail)
They both have master detail relationship

#Both of them have Two record types each
> contact has record type "Con1" and "con2"
> cust__c has record type "Cus1" and "Cus2"

#Other info
> the detail page layout is present on the parent object

#Requirement
> I want to make sure that if a new "cust__c" is created on contact with record type "Con1" then mandatorily it should be associated to "Cus1".
> Similaryly, "Con2" should be associated to "Cus2", 
> Both of the association should be mandatory for a user

How is it possible ?
Best Answer chosen by Ab
James WooleyJames Wooley
The only way I can think of doing this is with a custom 'new' button on the cust__c related object of the contact. Using a URL override you could set the record type of the cust__c based on the record type of the parent contact.

Here's a nice blog about URL hacking:

http://www.salesforceben.com/salesforce-url-hacking-tutorial/

All Answers

James WooleyJames Wooley
Have you tried a validation rule on cust__c?

Something like

AND(
    NOT( AND(contact.RecordType = 'con1', RecordType = 'cus1')),
    NOT( AND(contact.RecordType = 'con2', RecordType = 'cus2'))
)
AbAb
the validation rule will fire when saving the file but i want to force the user to use specific record type by default, 
James WooleyJames Wooley
The only way I can think of doing this is with a custom 'new' button on the cust__c related object of the contact. Using a URL override you could set the record type of the cust__c based on the record type of the parent contact.

Here's a nice blog about URL hacking:

http://www.salesforceben.com/salesforce-url-hacking-tutorial/
This was selected as the best answer