Am having JQuery auto complete search box in visualforce page. Currently the input for this search box is(ajax data) JSON. Which is a static resource file. But If client add one more option in the picklist field then they can't able find that option in the auto complete search box. So, I want to make it as dynamic. So decided to get the values in apex and form a JSON and pass the JSON data from apex to ajax call.
Picklist Field Names
Technology - Controlling picklist
Sub Technology - Dependent Picklist
Currently my static resource JSON file is looking like this(sample),
[
{
"techarea":"Dotnet",
"subtecharea":"Csharp",
"keywords":"",
"label":"Dotnet => Csharp => "
},
{
"techarea":"Dotnet",
"subtecharea":"ASP",
"keywords":"",
"label":"Dotnet => ASP => "
},
{
"techarea":"JAVA",
"subtecharea":"JSP",
"keywords":"",
"label":"JAVA => JSP => "
}
]
Am trying with Schema Picklist Entries method but can't able to build with controller and dependent format. Really appreciable if anyone help me to achieve this.
Updated:
Sample Class Am trying to build
public class CreateJSONFromPicklists {
public void createFromCaseTATSAPicklists(){
Schema.DescribeFieldResult TAfieldResult = Case.Technology_Area__c.getDescribe();
Schema.DescribeFieldResult TSAfieldResult = Case.Sub_Technology_Area__c.getDescribe();
List<Schema.PicklistEntry> TAple = TSAfieldResult.getPicklistValues();
List<Schema.PicklistEntry> TSAple = TSAfieldResult.getPicklistValues();
Transient String buildJSON = '';
for( Schema.PicklistEntry TAf : TAple)
{
for(Schema.PicklistEntry TSAf: TSAple){
// options.add(new SelectOption(f.getLabel(), f.getValue()));
buildJSON += '{"techarea":'+ TAf.getValue()+',"subtecharea":'+TSAf.getValue()+',"keywords":"","label":"'+TAf.getValue()+' => '+TSAf.getValue()+' => "},';
}
}
system.debug('@@@ BuildJSON @@@ '+buildJSON);
//return options;
}
}
But apex heap size issue is throwing here. Also doubt on controlling dependent values format.