0

We have a requirement where we have to automate record type selection of child objects based on the record type of master. For example there is an object X (master) with 3 record types (r1,r2 and r3). The child object(Y) has similar record types i.e r1, r2 and r3. Now if an user creates a record in X of recordtype r1 and goes on to create a record on Y using the new button on the related list then the record selection page shouldn't be displayed and the user will be taken straight into the specific page for the particular record type i.e r1.

How can we achieve this?

3
  • there are multiple options 1) Override the new button with Visualforce and pass the RecordTypeId in the URL. 2) Use workflow (I prefer this option as it does not need any apex). Select any record type and use Create a workflow to update recordtypeid based on Parent Record. But this will not skip the record type selection page
    – C0DEPirate
    Commented May 3, 2016 at 12:02
  • Frankly i would like an approach without code so I took help of this link sfdcwizards.com/archives/47/automatic-record-type-selection but the problem is this is not dynamic.
    – Sagnik
    Commented May 3, 2016 at 12:12
  • 1
    You can use WF to make it dynamic, no need to override button
    – C0DEPirate
    Commented May 3, 2016 at 12:20

2 Answers 2

2

You can achieve this by creating three custom list buttons on the child object, one for each record type.

The content type of the button should be URL and the URL should look something like this.

/xxx/e?CF00ND000000xxxx={!X.Name}&CF00ND000000xxxx_lkid={!X.Id}&retURL=%2F{!Account.Id}&RecordTypeId='ChildRecordTypeId_R1'

Change the 'xxx' to key prefix of your custom object x and field Id 'CF00ND000000xxxx' field id of the lookup field x on your child object.

Create different page layouts for each recordtype in X. Expose the each of list of the child list button in each layout.

Hope this is helpful.

1
  • I did follow this exact approach but the problem I'm facing here is that I've to hardcode the child record type Id for RecordType parameter . Can we avoid this hardcoding by using any merge fields? Also for specifying the custom field Id (like CF00ND000000xxxx) is there any way we can do this dynamically other than hardcoding the field Id itself?
    – Sagnik
    Commented May 4, 2016 at 5:24
0

You could achieve this using url hacking as K.Sambaraju is proposing, but this is not supported by Salesforce.

A cleaner way of doing this would be to create actions instead. Chatter feed tracking would have to be enabled on your master object to accomplish this.

Go to Buttons, Links, and Actions and create a new action of type Create a Record and choose the appropriate record type. From there on, it should be pretty self explanatory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .