function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sh-at-youseesh-at-yousee 

A multi-select picklist of objects...

Hi,

 

We're facing a bit of a challenge in my company and I hope someone here might be able to help.

 

The first challenge might be a bit off-topic but I'll give it a go anyway. How can one model a recursive data structure in SFDC?

 

Basically, we have a custom object called Sales Products which has a type. When type is "Bundle", we would like to be able to link a number of other Sales Products (same object but different type) to it.

 

The second challenge is displaying the Sales Products to select. It would be nice if we could list the existing Sales Products in e.g. a multi-select picklist but as I understand it the inputField shown is based on the actual type of field on the object (i.e. a text field will give a text field, a picklist will give a picklist and so on).

 

Does anyone have any good ideas on how to achieve both recursive data structure and a user friendly way of displaying the recursive link?

 

Cheers.

 

Søren Nødskov Hansen

Best Answer chosen by Admin (Salesforce Developers) 
AvromAvrom

In answer to your first question, you use a field of type lookup. There's nothing that prevents lookups from being recursive (and in fact many built-in lookups, like Account.ParentAccount, are).

 

<apex:inputField> does base its form on the underlying datatype of the object. But there are other options for displaying data, such as <apex:selectList>.

 

But what I'd really recommend is trying to use a list view, like <apex:enhancedList>, and create a custom button on it which assigns all selected rows to whatever master row you specify. You can learn more about this process in the Apex Pages Developer's Guide. See especially "Adding Custom List Buttons Using Standard List Controllers."