1

Scenario: I have a Visualforce Page on which users create Quote Line Items based on a custom search function. First, they select the product. Next, they fill in some values that come from a FieldSet, i.e. Sales Price. There is also a picklist on Quote Line Items that needs filled in, but the values of this picklist should be based on the Record Type of the selected product. In other words, the picklist on Quote Line Items should function like a dependent picklist across objects.

Question: What is the best way to make a "dependent picklist" across objects?

Suggested solution: I don't think it's possible to create a dependent picklist across these objects, so I have thought of the following solution. First, I create a new picklist on Quote Line Item holding the same values as the Product Record Type. Next, I set the value of this field in Apex and add it (as hidden field) to the VisualForce page where they fill in the fields for their new Quote Line Item. Lastly, I set my picklist up to be a dependent picklist based on this new picklist.

Is this the best solution for my problem, or are there better ways to do this?

  • Have a look at the decorator pattern in salesforce from this link: developer.salesforce.com/page/Apex_Design_Patterns. As the description says: The Decorator pattern attempts to solve the issue where you need temporary fields for processing (typically in Visualforce) but do not need to add these fields to the sObject. Let me know if it helped. – Mihai Neagoe Apr 30 '15 at 8:55
  • I do know the decorator pattern, but don't think it helps in my scenario: The temporary field has to be controlling for an existing picklist field on my object. Putting it in a wrapper won't help me determine the values on the existing picklist based on the Product Record Type, right? – Koen Wesselman Apr 30 '15 at 9:18
1

I like you solution very much. It is simple, allow us to use standard functionality. Only thing missing for me is custom setting. There should be simple way that allow user decide what record type match what value of picklist. Such mapping will be easy to maintain and more flexible that direct assigning in the code.

  • That's definitely a good addition to the suggested solution, thanks! I'm also not entirely happy about how users will have to manually keep Product Record Types and the new picklist in sync though, are you aware of any solution for that issue? – Koen Wesselman Apr 30 '15 at 11:11
  • Actually, Custom Settings wouldn't be necessary because the dependent picklist will take care of that. :-) Custom settings would only be necessary when opting for a code solutions, right? – Koen Wesselman Apr 30 '15 at 12:05

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.