I have two custom settings WSList and PList in a single method . I want to add these two lists i.e., under WSList , Plist should come as a related List . i am writing this code in utility class but not in controller or vf page Can any help me in resolving this?

edit: Thanks for the reply . Actually , i am mapping data from one custom object to 4 different custom settings . after mapping is done , In the custom settings , i have warranty , part , driver list custom settings , now here my problem is i need to have a either warranty list and part as related list or warra list and driver as related list to warranty list. this entire function should work in a single method only .

  • 1
    Welcome to the forum! It's not entirely clear that what you want is possible. A related list appears as a result of an object having a parent-child relationship. Custom Settings are a kind of object but they cannot have lookup (parent) relationships to each other. Perhaps if you can post some code or information on how WSList and PList are defined in Salesforce this would help. – Doug B Sep 25 '13 at 10:19

As Doug B, noted it's not entirely clear what your trying to do. That said, I'm going to take a stab at this and venture that you're trying to add two List object's together. If that's the case, here's how to do that if both Lists contain the same object type. For demonstration purposes, I'm going to use list type of string.

List<String> WSList; // I'm assuming this is populated in someway
List<String> PList; // Likewise.
WSList.addAll(PList); // WSList now contains the contents of WSList AND PList

You can find more information about the list methods here


Custom settings cannot be children (i.e. related lists) of other custom settings. From your description it sounds like these should have been created as Custom Objects not as Custom Settings. In order to use native SF functionality, page layouts and related lists, you will need to store the information in appropriately designed Custom Objects.

Custom settings are for things that you would commonly use .INI files in other systems.

In the custom objects, you can create one custom object called Warranty_c and another custom object called Part_c.

On the Part_c object you can create a lookup field to Warranty_c. This lets you specify when you load data which Warranty relates to that Part.

The Warranty is the parent object and so it has a related list of all Parts which are its children.


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.