You need to sign in to do that
Don't have an account?
B. Wade Lovell
Error: Unknown Property "String.Services__c
I have the following very simple VF page to display two dependent picklists (3 tiers total) using a custom controller. When I attempt to save the VF page, I get the error message above.
In the developer console, I see two Problems at Line 0. 1) ABS_Services_Input, Unknown property 'String.Services__c and 2) "Duplicate value found: duplicates value on record with id:" (Yes, literally. No id # given.)
<apex:page controller="ABSServicesController">
<apex:messages style="color:red"></apex:messages>
<apex:form >
<apex:pageBlock title="Dependent Picklist Entry">
<apex:repeat value="{!serviceList}" var="svcItem">
<apex:pageBlockSection title="{!svcItem.Services__c}" columns="1">
<apex:pageBlockSection title="{!svcItem.Capabilities__c}" columns="1">
<apex:pageBlockSection title="{!svcItem.Sub_Capabilities__c}" columns="1">
</apex:pageBlockSection>
</apex:pageBlockSection>
</apex:pageBlockSection>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
This is my Custom Controller code:
public with sharing class ABCServicesController{
public String serviceList { get; set; }
public List<ServiceOffered__c> servicesList{get;set;}
public Map<String, Map<String, List<String>>> serviceMap{get;set;}
public ABCservicesController(){
serviceMap = new Map<String, Map<String, List<String>>>();
servicesList = [Select ID, Services__c, Capabilities__c, Sub_Capabilities__c From ServiceOffered__c];
for(ServiceOffered__c svcItem : servicesList) {
if(serviceMap.containsKey(svcItem.Services__c)) {
if(serviceMap.get(svcItem.Services__c).containsKey(svcItem.Capabilities__c)) {
serviceMap.get(svcItem.Services__c).get(svcItem.Capabilities__c).add(svcItem.Sub_Capabilities__c);
} else {
serviceMap.get(svcItem.Services__c).put(svcItem.Capabilities__c, new List<String>{svcItem.Sub_Capabilities__c});
}
} else {
Map<String, List<String>> m = new Map<String, List<String>>();
m.put(svcItem.Capabilities__c, new List<String>{svcItem.Sub_Capabilities__c});
serviceMap.put(svcItem.Services__c, m);
//new Map<String, List<String>>{svcItem.Capabilities__c : new List<String>{svcItem.Capabilities__c}}
}
}
}
}
I do not know if it is relevant but earlier I was getting an unknow property error serviceList related to the line "Public List<ServiceOffered__c> serviceList{get;set;}".
My path toward resolution, besides asking all of you great folks, is to figure out why the variable svcItem was expected to be something other than a string when every service being pulled into the List is a string.
Thanks in advance,
Wade
In the developer console, I see two Problems at Line 0. 1) ABS_Services_Input, Unknown property 'String.Services__c and 2) "Duplicate value found: duplicates value on record with id:" (Yes, literally. No id # given.)
<apex:page controller="ABSServicesController">
<apex:messages style="color:red"></apex:messages>
<apex:form >
<apex:pageBlock title="Dependent Picklist Entry">
<apex:repeat value="{!serviceList}" var="svcItem">
<apex:pageBlockSection title="{!svcItem.Services__c}" columns="1">
<apex:pageBlockSection title="{!svcItem.Capabilities__c}" columns="1">
<apex:pageBlockSection title="{!svcItem.Sub_Capabilities__c}" columns="1">
</apex:pageBlockSection>
</apex:pageBlockSection>
</apex:pageBlockSection>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
This is my Custom Controller code:
public with sharing class ABCServicesController{
public String serviceList { get; set; }
public List<ServiceOffered__c> servicesList{get;set;}
public Map<String, Map<String, List<String>>> serviceMap{get;set;}
public ABCservicesController(){
serviceMap = new Map<String, Map<String, List<String>>>();
servicesList = [Select ID, Services__c, Capabilities__c, Sub_Capabilities__c From ServiceOffered__c];
for(ServiceOffered__c svcItem : servicesList) {
if(serviceMap.containsKey(svcItem.Services__c)) {
if(serviceMap.get(svcItem.Services__c).containsKey(svcItem.Capabilities__c)) {
serviceMap.get(svcItem.Services__c).get(svcItem.Capabilities__c).add(svcItem.Sub_Capabilities__c);
} else {
serviceMap.get(svcItem.Services__c).put(svcItem.Capabilities__c, new List<String>{svcItem.Sub_Capabilities__c});
}
} else {
Map<String, List<String>> m = new Map<String, List<String>>();
m.put(svcItem.Capabilities__c, new List<String>{svcItem.Sub_Capabilities__c});
serviceMap.put(svcItem.Services__c, m);
//new Map<String, List<String>>{svcItem.Capabilities__c : new List<String>{svcItem.Capabilities__c}}
}
}
}
}
I do not know if it is relevant but earlier I was getting an unknow property error serviceList related to the line "Public List<ServiceOffered__c> serviceList{get;set;}".
My path toward resolution, besides asking all of you great folks, is to figure out why the variable svcItem was expected to be something other than a string when every service being pulled into the List is a string.
Thanks in advance,
Wade
<pre>
public with sharing class ABCServicesController
{
public List<ServiceOffered__c> servicesList { get; set; }
public Map<String, Map<String, List<String>>> serviceMap { get; set; }
public ABCservicesController()
{
serviceMap = new Map<String, Map<String, List<String>>>();
servicesList = [Select ID, Services__c, Capabilities__c, Sub_Capabilities__c From ServiceOffered__c];
for ( ServiceOffered__c svcItem : servicesList )
{
if ( !serviceMap.containsKey( svcItem.Services__c ) )
{
serviceMap.put( svcItem.Services__c, new Map<String, List<String>>() );
}
Map<String, List<String>> capabilitiesMap = serviceMap.get( svcItem.Services__c );
if ( !capabilitiesMap.containsKey( svcItem.Capabilities__c ) )
{
capabilitiesMap.put( svcItem.Capabilities__c, new List<String>() );
}
capabilitiesMap.get( svcItem.Capabilities__c ).add( svcItem.Sub_Capabilities__c );
}
}
}
</pre>
All Answers
<pre>
public with sharing class ABCServicesController
{
public List<ServiceOffered__c> servicesList { get; set; }
public Map<String, Map<String, List<String>>> serviceMap { get; set; }
public ABCservicesController()
{
serviceMap = new Map<String, Map<String, List<String>>>();
servicesList = [Select ID, Services__c, Capabilities__c, Sub_Capabilities__c From ServiceOffered__c];
for ( ServiceOffered__c svcItem : servicesList )
{
if ( !serviceMap.containsKey( svcItem.Services__c ) )
{
serviceMap.put( svcItem.Services__c, new Map<String, List<String>>() );
}
Map<String, List<String>> capabilitiesMap = serviceMap.get( svcItem.Services__c );
if ( !capabilitiesMap.containsKey( svcItem.Capabilities__c ) )
{
capabilitiesMap.put( svcItem.Capabilities__c, new List<String>() );
}
capabilitiesMap.get( svcItem.Capabilities__c ).add( svcItem.Sub_Capabilities__c );
}
}
}
</pre>