Loading
Salesforce Enforces New Security Requirements in Summer 2026Read More
Get Started with Communications, Media, and Energy & Utilities (CME)...
EligibilityMatrixFlowImplementation

EligibilityMatrixFlowImplementation

The EligibilityMatrixFlowImplementation calls the Eligibility Matrix flow, which executes defined eligibility rules. The EligibilityMatrixFlowImplementation and the Eligibility Matrix flow are part of the unmanaged package. To use the EligibilityMatrixFlowImplementation, the Eligibility Matrix flow must exist in the org.

The Eligibility Matrix flow has one eligibility matrix action that invokes the Eligibility Matrix Calculation Service. The eligibility matrix action passes in the following parameters to the Eligibility Matrix Calculation Service:

  • dataRaptorBundle: The Omnistudio Data Mapper bundle used to extract product-related information and attributes.

  • matrixName: The name of the calculation matrix used to evaluate eligibility.

  • includeMissing: A Boolean flag that indicates whether Products that do not match any matrix rows are considered eligible.

The eligibility matrix action is also passed Price Book Entry objects, which are marked as either qualified or not qualified based on matching product rows from the matrix calculation output. Qualified price book entries mean the associated products are eligible to the user.

Triggered When

The ProductEligibilityOpenInterfaceProductEligibilityOpenInterface is triggered when presenting a list of Products in the Opportunity Manager, Order Manager, Quote Manager, or Vlocity Cart. The ProductEligibilityOpenInterface calls the EligibilityMatrixFlowImplementation.

Interface

VlocityOpenInterface

Sample Code

global with sharing class EligibilityMatrixFlowImplementation implements VlocityOpenInterface
{
   global Flow.Interview.EligibilityMatrixFlow myFlow
   {
      get;set;
   }
   global Boolean invokeMethod(string methodName, Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
   {
      Boolean success = true;
      try
      {
         if(outputMap == null)
         {
            outputMap = new  Map<string, object>();
         }
         if(methodName == 'getAllEligibilityProducts')
         {
            SObject header = (SObject)inputMap.get('parentItem');
            List<PricebookEntry> pricebookEntryList = (List<PricebookEntry>)inputMap.get('pricebookEntryList');
            outputMap.put('itemWrapperList', getAllEligibilityProducts(header, pricebookEntryList));
         }
         else if(methodName == 'getEligibleProducts')
         {
            SObject header = (SObject)inputMap.get('parentItem');
            List<PricebookEntry> pricebookEntryList = (List<PricebookEntry>)inputMap.get('pricebookEntryList');
            outputMap.put('eligiblePricebookEntryList', getEligibleProducts(header, pricebookEntryList));
         }
      }
      catch(Exception e)
      {
         success = false;
      }
      return success;
   }
   public List<ItemWrapper> getAllEligibilityProducts(SObject header, List<PriceBookEntry> retval)
   {
      doEligibility(header, retval);
      Map<Id, ItemWrapper> pbMap = (Map<Id, ItemWrapper>)FlowStaticMap.flowMap.get('pricebookIdToItemWrapper');
      List<ItemWrapper> pbWrappers = pbMap.values();
      List<ItemWrapper> result = new  List<ItemWrapper>();
      for(Integer index = 0; index < retval.size(); index++)
      {
         ;result.add(pbMap.get(retval[index].Id));
      }
      return result;
      }
      public List<PriceBookEntry> getEligibleProducts(SObject header, List<PriceBookEntry> retval)
      {
         doEligibility(header, retval);
         Map<Id, ItemWrapper> pbMap = (Map<Id, ItemWrapper>)FlowStaticMap.flowMap.get('pricebookIdToItemWrapper');
         List<ItemWrapper> pbWrappers = pbMap.values();
         List<PriceBookEntry> filteredPricebookEntries = new  List<PriceBookEntry>();
         for(Integer index = 0; index < pbWrappers.size(); index++)
         {
            if(pbWrappers[index].isQualified == false)
            {
               continue;
            }
      filteredPricebookEntries.add((PricebookEntry)pbWrappers[index].itemSObject);
         }
         return filteredPricebookEntries;
      }
   private void doEligibility(SObject header, List<PriceBookEntry> retval)
   {
      Map<Id, ItemWrapper> pricebookIdToItemWrapper = new  Map<Id, ItemWrapper>();
      for(integer index = 0; index < retval.size(); index++)
      {
            pricebookIdToItemWrapper.put(retval[index].Id, new  ItemWrapper(retval[index]));
      }
      string objectName = string.valueOf(header.getSObjectType());
      Id headerId = header.Id;
      List<Sobject> sobjectsList = new  List<Sobject>();
      if(objectName == 'Order')
      {
         sobjectsList = [SELECT
            Id
         FROM
            OrderItem
         WHERE
            OrderId = : headerId];
      }
      else if(objectName == 'Quote')
      {
         sobjectsList = [SELECT
            Id
         FROM
            QuoteLineItem
         WHERE
            QuoteId = : headerId];
      }
      else if(objectName == 'Opportunity')
      {
         sobjectsList = [SELECT
            Id
         FROM
            OpportunityLineItem
         WHERE
            OpportunityId = : headerId];
      }
      FlowStaticMap.flowMap.put('itemList', new List<SObject>{header});
      FlowStaticMap.flowMap.put('parentObjectList', new List<SObject>{header});
      FlowStaticMap.flowMap.put('childItemsList', sobjectsList);
      FlowStaticMap.flowMap.put('pricebookIdToItemWrapper', pricebookIdToItemWrapper);
      Map<string, object> myMap = new  Map<string, object>();
      myMap.put('parentType', objectName);
      myFlow = new  Flow.Interview.EligibilityMatrixFlow(myMap);
      try
      {
         myFlow.start();
      }
      catch(System.FlowException e)
      {
         System.debug(LoggingLevel.ERROR, 'exception::::' + e);
      }
   }
}

Related Implementations

  • AccountTypeProductEligibilityImplementationAccountTypeProductEligibilityImplementation

  • DefaultEligibilityOpenImplementationDefaultEligibilityOpenImplementation

  • DefaultProductEligibilityImplementationDefaultProductEligibilityImplementation

  • FilterEligibilityImplementationFilterEligibilityImplementation

  • EligibilityFlowOpenImplementationEligibilityFlowOpenImplementation

  • EligibilityRulesFlowImplementationEligibilityRulesFlowImplementation

 
Loading
Salesforce Help | Article