1

I have a parent object Contract__c and a child record Risk__c. The parent object has a picklist: Classification: high, medium, low

Risk__c has two record types high and low. The fields for these record types are different, and I have created a visualforce page for each record type, because I need to modify the save&new functionality.

When the user enters high on Contract__c, the user needs to click on the related list button Create high risk, which opens the high risk visualforce page. I have another button called Create medium risk, which the user should click if medium was selected in the classification picklist.

The problem is, I want to only display the high button if high was selected in the picklist, and I want to be able to display the medium button, only if medium was selected. Is that possible?

Otherwise I would be happy to just have one button, which has some logic to decide which page to open. But I wouldn't know how to do that.

Tia.

  • In case your Create X risk button is a custom button why can't you just check the parent's picklist value before redirecting to the creation page? Something like IF(ISPICKVAL(Classification, "high"), "VisualforcePage1", "VisualforcePage2") – Sergej Utko Feb 18 '15 at 12:11
  • But would that be a url, javascript or visualforce page? When I select visualforce page as my content source, then I am not able to do that. – Lily Feb 18 '15 at 12:36
  • You can redirect to the visualforce page using javascript. – Sergej Utko Feb 18 '15 at 12:41
0
  • You can create one custom field on your Custom object "Contract__c" which holds the name of visualforce page lets call it as "Page__c".
  • The value of Page__c will change according to value of Classification: high, medium, low
    e.g.
    if
    Classification == high
    then
    page__c = 'HighVFPage';
  • This page__c would be formula field which contains formula like
    CASE(Classification, "high", "HighVFPage", "medium", "MediumVFPage","LowVFPage")
  • Create List button on child object("Risk__c") which contains below code.
    var pageValue = "{!Contract__c.Page__c}"; 
    var url = "/apex/"+pageValue; 
    parent.window.location = url; 
    

I hope this will work for you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.