0

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?

3
  • 3
    and have you tried anything yet?
    – cropredy
    Dec 16, 2014 at 20:38
  • Hi, yes, I have tried creating a new List Button, but I cannot find out how to specify the record type in the link. This is the code I am using for the List Button: {!IF(ISPICKVAL(Cov__c.Risk__c,'Terr'), '/a0Z/e' , 'a0Z/e')}
    – Lily
    Dec 18, 2014 at 10:54
  • Hello @crop1645 - I have amended my code once again. Are you able to help me see why this is not working?
    – Lily
    Dec 18, 2014 at 11:33

1 Answer 1

2

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.

10
  • Can I use that syntax in a list button?
    – Lily
    Dec 18, 2014 at 14:38
  • @Lily Sorry, I should refrain from answering on my phone app, didn't read the url correctly ent= 01I180000004KaV should be fine, I thought that was the retURL parameter you were setting. The easiest thing to do is create a new record with the standard new button then copy the url and wherever it has the parent record id swap it out with the merge field. Once you have it working for a single record type then add the if statement and swap out the record id where needed. I'll update my answer with how it should probably end up looking.
    – Jenny B
    Dec 18, 2014 at 15:48
  • Thanks @Jenny B, Do you know how I can actually make the link work on the button?
    – Lily
    Dec 18, 2014 at 16:01
  • @Lily I added an example of what the URL should look like in the end.
    – Jenny B
    Dec 18, 2014 at 16:10
  • I have changed my code for the button now. /006/e?retURL={!Cov__c.Id}&CustomFieldIDFromChildRecord={!Cov__c.Id}&RecordType={!IF(ISPICKVAL(Cov__c.Risk__c,'Terr'), "012180000008Tw0","012180000008Tw5")}&ent=Address__c and when I click on it, I get an error message saying "Insufficient Privileges". I wonder why this would be?
    – Lily
    Dec 18, 2014 at 20:27

You must log in to answer this question.

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