1global with sharing class CtxRuleFunctionApex implements VlocityOpenInterface {
2
3 global Boolean invokeMethod(String methodName, Map<String, Object> inputs, Map<String, Object> output, Map<String, Object> options) {
4
5 if (methodName == 'ProductInOrder') {
6 productInOrder(inputs, options, output);
7 }
8 return true;
9 }
10
11 //Argument1: ProductCode to be checked
12 //Output: return true if product exists in the given order else false
13 public void productInOrder(Map<String, Object> inputMap, Map <String, Object> options, Map<String, Object> outMap) {
14
15 List <Object> arguments = (List <Object>) inputMap.get('arguments');
16 Boolean result = false;
17 outMap.put('result', false);
18 if (arguments != null && arguments.size() == 1 && arguments[0] != null) {
19 String prodCode = (String)arguments[0];
20 System.debug ('PRODUCT CODE: ' + prodCode);
21
22 CpqCartDocument cartDocument = (CpqCartDocument)FlowStaticMap.flowMap.get('cartDocument');
23 // update result variable based on your conditions
24
25 outMap.put('result', result);
26 }
27 System.debug('result ---- ' + JSON.serialize(outMap));
28 }
29}