/*
author: Balayesu
description: This class sets select element values dynamically in Dental questions omniscript
*/
global with sharing class DentalQuestionsOmniscriptController implements vlocity_ins.VlocityOpenInterface {
public String groupId;
public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options){
boolean flag=false;
System.debug('Setting inputSelect options');
if(methodName.equals('getSICcodes')){
flag=getSICcodes(input,outMap,options);
}
if(methodName.equals('getSICcodesTypeAhead')){
flag=getSICcodesTypeAhead(input,outMap,options);
}
return flag;
}
//get options for select element
public boolean getSICcodes(Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options){
Map<String,String> dupmap=new Map<String,String>();
List<Map<String,String>> selectoptions=new List<Map<String,String>>();
String contacttypes='';
for(Standard_Industry_Code__c c:[SELECT Name FROM Standard_Industry_Code__c where Name!=null]){
contacttypes+=c.Name+';';
}
List<String> ctlist=new List<String>();
if(contacttypes.contains(';')){
for(String s:contacttypes.split(';')){
if(s!='' && s!=null){
if(!dupmap.containsKey(s)){
ctlist.add(s);
dupmap.put(s,s);
}
}
}
}
System.debug('ctlist :'+ctlist);
for(String s:ctlist){
selectoptions.add(new Map<String,String>{'name'=>s,'value'=>s});
}
System.debug('selectoptions: '+selectoptions);
outMap.put('options',selectoptions);
boolean flag=true;
return flag;
}
public boolean getSICcodesTypeAhead(Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options){
Map<String,String> dupmap=new Map<String,String>();
List<Map<String,String>> selectoptions=new List<Map<String,String>>();
String contacttypes='';
try{
System.debug('input :'+JSON.serialize(input));
List<Map<String,String>> lookupoptions=new List<Map<String,String>>();
String filter1;
//Fetch individual consumer data
if(input.containsKey('QuestionsStep')){
Map<String,Object> stepPA=(Map<String,Object>)input.get('QuestionsStep');
Map<String,Object> memblock=(Map<String,Object>)stepPA.get('SICTypeAhead-Block');
filter1=(string)memblock.get('SICTypeAhead');
}
filter1=filter1.trim();
string filter=filter1+'%';
System.debug('filter :'+filter);
for(Standard_Industry_Code__c c:[SELECT Id,Name,SIC_Description__c FROM Standard_Industry_Code__c where Name LIKE :filter]){
lookupoptions.add(new Map<String,String>{'SICId'=>String.valueOf(c.id),'SIC'=>String.valueOf(c.Name + ' - ' +c.SIC_Description__c)});
}
system.debug('suggestions: '+lookupoptions);
outMap.put('suggestions',lookupoptions);
}catch(exception ex){
System.debug('The following exception has occurred: ' + ex.getMessage());
System.debug('Stacktrace -- The following exception has occurred: ' + ex.getStackTraceString());
}
return true;
//====================end of new code ======================
}
}
Below is the configuration for the typeahead element
author: Balayesu
description: This class sets select element values dynamically in Dental questions omniscript
*/
global with sharing class DentalQuestionsOmniscriptController implements vlocity_ins.VlocityOpenInterface {
public String groupId;
public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options){
boolean flag=false;
System.debug('Setting inputSelect options');
if(methodName.equals('getSICcodes')){
flag=getSICcodes(input,outMap,options);
}
if(methodName.equals('getSICcodesTypeAhead')){
flag=getSICcodesTypeAhead(input,outMap,options);
}
return flag;
}
//get options for select element
public boolean getSICcodes(Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options){
Map<String,String> dupmap=new Map<String,String>();
List<Map<String,String>> selectoptions=new List<Map<String,String>>();
String contacttypes='';
for(Standard_Industry_Code__c c:[SELECT Name FROM Standard_Industry_Code__c where Name!=null]){
contacttypes+=c.Name+';';
}
List<String> ctlist=new List<String>();
if(contacttypes.contains(';')){
for(String s:contacttypes.split(';')){
if(s!='' && s!=null){
if(!dupmap.containsKey(s)){
ctlist.add(s);
dupmap.put(s,s);
}
}
}
}
System.debug('ctlist :'+ctlist);
for(String s:ctlist){
selectoptions.add(new Map<String,String>{'name'=>s,'value'=>s});
}
System.debug('selectoptions: '+selectoptions);
outMap.put('options',selectoptions);
boolean flag=true;
return flag;
}
public boolean getSICcodesTypeAhead(Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options){
Map<String,String> dupmap=new Map<String,String>();
List<Map<String,String>> selectoptions=new List<Map<String,String>>();
String contacttypes='';
try{
System.debug('input :'+JSON.serialize(input));
List<Map<String,String>> lookupoptions=new List<Map<String,String>>();
String filter1;
//Fetch individual consumer data
if(input.containsKey('QuestionsStep')){
Map<String,Object> stepPA=(Map<String,Object>)input.get('QuestionsStep');
Map<String,Object> memblock=(Map<String,Object>)stepPA.get('SICTypeAhead-Block');
filter1=(string)memblock.get('SICTypeAhead');
}
filter1=filter1.trim();
string filter=filter1+'%';
System.debug('filter :'+filter);
for(Standard_Industry_Code__c c:[SELECT Id,Name,SIC_Description__c FROM Standard_Industry_Code__c where Name LIKE :filter]){
lookupoptions.add(new Map<String,String>{'SICId'=>String.valueOf(c.id),'SIC'=>String.valueOf(c.Name + ' - ' +c.SIC_Description__c)});
}
system.debug('suggestions: '+lookupoptions);
outMap.put('suggestions',lookupoptions);
}catch(exception ex){
System.debug('The following exception has occurred: ' + ex.getMessage());
System.debug('Stacktrace -- The following exception has occurred: ' + ex.getStackTraceString());
}
return true;
//====================end of new code ======================
}
}
Below is the configuration for the typeahead element
No comments:
Post a Comment