You need to sign in to do that
Don't have an account?
Need help creating a Map
I am seeking to develop a Map which can hold selected values from a user on a viusal force page
I have three variables in context:
1) Service_Area__c - SObject
2) Postal Code - String
3) Product2 - SObject
Each Service Area selection has a Postal Code and each Service Area/Postal Code combination has multiple Product selections.
My logic is to combine Service_Area__c and Postal Code in one virtual object called eServiceArea.
I am attempting to create a map like the following:
Map<eServiceArea, List<Product2>> Map_ServiceAreaList_ServiceTasksList = new Map<eServiceArea, List<Product2>>();
Using some code I found in a wrapper class, assuming its relevant:
public class eServiceArea { public Service_Area__c SA {get; set;} public string PostalZipCode {get; set;} public eServiceArea (Service_Area__c eSA, String ePostalZipCode) { SA = eSA; PostalZipCode = ePostalZipCode; } }
The map will not allow me to save with eServiceArea. I am not sure if creating a eServiceArea Class is what I need, please provide some direction.
Thanks,
RN
I want to make sure I understand this correctly:
1) There is a 1 to 1 relationship between Service_Area__c and Postal Code.
2) There is a 1 to many relationship between Service_Area__c and Product2.
Assume I've got that right, I woudl recommend a class like this:
Depending on how you need to access the data, you could use a list of eServiceArea objects, or a map based on Service_Area__c.Id or PostalZipCode. Examples are below: