Preprocessor Class Example (Managed Package)

For the managed package runtime, the following example shows the typical structure of a preprocessor Apex class for a declarative Calculation Procedure.

Managed Package app icon This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.

global with Sharing class PricingCalculationPreProcessExample implements VlocityOpenInterface {

   public Boolean invokeMethod(String methodName, Map<String,Object> inputMap, Map<String,Object> outMap, Map<String,Object> options) {
        Boolean success = true;
        try{
            if(methodName == 'calculate') {             
                 calculation(inputMap, outMap, options);                
            }
          }catch(Exception e){
                    logger.err(e);
                    success=false;
         }

        return success;        
    }
    
    private static void calculation(Map<String,Object> inputMap, Map<String,Object> outMap, Map<String,Object> options){
         Logger.dbg('in preprocess input map is '+inputMap);
         for(String key : inputMap.keySet()){
         	if(key == 'ABCD1234'){
	         	Object realData = inputMap.get(key);
	         	Map<String, Object> real = (Map<String, Object>) realData;
	         	for(String key1 : real.keySet()){
	         		if(key1=='Payor_code'){
	         			real.put('Payor_code', 'kpf');
	         		}
	         	}
	         }
         }
         Logger.dbg(' in preprocess after conversion, input map is '+inputMap);
    }
    
  }