[SalesForce] Choose record type based on picklist value

I have a custom object Cov__c and I have a picklist on that object Risks_c.

I have another custom object Address__c, which is a child of Cov__c. I have two record types for Address__c because I need to display different fields on the page layout, based on the value that's selected in the Risks__c picklist.

The record types are called Auth_Risk and Terr_Risk.

So, when the user selects Auth in the Risks__c picklist, and then adds addresses to the contract, then I need to show the Auth_Risk record type. For any other value in the picklist, I need to show the Terr_Risk record type.

I have created a list button and added this code:

`{!IF( ISPICKVAL(Cov__c.Risk__c,'Terr'), '/a0Z/e?ent=01I180000004KaV&RecordType=012180000008Tw5, '/a0Z/e?ent=01I180000004KaV&RecordType=012180000008Tw0')}`

When I try to save, it just says error. I am not sure what is wrong. Can anyone help please?

Best Answer

As mentioned in my comment try getting the button to work on a single record type first then add in the if statement. An example of the result should look something like below:

/006/e?retURL={!Cov__c.Id}&CustomFieldIDFromChildRecord={!Cov__c.Id}&RecordType={!IF(ISPICKVAL(Cov__c.Risk__c,'Terr'), "012180000008Tw5","012180000008Tw0")}&ent=Opportunity  

since the only thing in the URL that is conditional is the Record Type Id, you can just use the IF statement for the RecordType parameter.

Related Topic