Monday, 17 July 2017

Vlocity - Populating Type a head block values from Remote Class

Below is the remote class,


global with sharing class TypeBlockMemberNameFilter implements vlocity_ins.VlocityOpenInterface {
   public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options)
   {
       System.debug('input :'+input);
       List<Map<String,String>> lookupoptions=new List<Map<String,String>>();
       Map<String,Object> step=(Map<String,Object>)input.get('Create Group Step');
       Map<String,Object> memblock=(Map<String,Object>)step.get('MemberName1-Block');
       String filter=memblock.get('MemberName1')+'%';
       System.debug('filter :'+filter);
       Map<String,String> dupcheckMap=new Map<String,String>();
       for(vlocity_ins__Party__c p:[Select Id,vlocity_ins__AccountId__c,vlocity_ins__AccountId__r.Name
                                    from vlocity_ins__Party__c where vlocity_ins__AccountId__r.Name like :filter limit 10]){
                                        if(!dupcheckMap.containsKey(String.valueOf(p.vlocity_ins__AccountId__c))){
                                        lookupoptions.add(new Map<String,String>{'Id'=>String.valueOf(p.vlocity_ins__AccountId__c),'Name'=>String.valueOf(p.vlocity_ins__AccountId__r.Name,'PartyId1'=>String.valueOf(Id))});
                                        dupcheckMap.put(String.valueOf(p.vlocity_ins__AccountId__c),String.valueOf(p.vlocity_ins__AccountId__r.Name));
                                        }
       }   
       outMap.put('suggestions',lookupoptions);
       return true;
   }
}

No comments:

Post a Comment