Loading
The online Trailblazer Community becomes read-only Oct 30, 2026Read More
Important Advisory: iOS Update Impacting CG Mobile ApplicationRead More
Get Started with Communications, Media, and Energy & Utilities (CME)...
DefaultProductEligibilityImplementation

DefaultProductEligibilityImplementation

The DefaultProductEligibilityImplementation handles product eligibility by returning different outputs based on the presence of PriceBookEntry (PBE) records in the input.

  • No PriceBookEntry records in input: It retrieves and returns all PBEs related to the Pricebook associated with the parent entity (e.g., Order, Quote, etc.).
  • PriceBookEntry records in input: It returns the input as output without any modification

Interface

ProductEligibilityInterface

Sample Code

global with sharing class DefaultProductEligibilityImplementation implements GlobalInterfaces.ProductEligibilityInterface
{
   /**
   @param item (SObject) : parent item ie Order, Quote or Oppty
   @param retval (List&ltPriceBookEntry&gt) : list of PBE processed so far
   @return List&ltPriceBookEntry&gt : filtered list
   @description This default implemtation returns the list it was passed (retval)
   or if that is null it returns back the complete list of PBE for the Pricebook on the parent item.
   */
   global List<PricebookEntry> getEligibleProducts(SObject item, List<PriceBookEntry> retval)
   {
      if(retval == null || (retval != null && retval.size() == 0))
      {
         retval = new  List<PriceBookEntry>();
         try
         {
            Id itemId = (Id)item.get('Pricebook2Id');
            retval = [SELECT
               Id,
               Pricebook2Id,
               Product2Id,
               ProductCode,
               Product2.Description,
               UnitPrice,
               Product2.Type__c,
               Product2.SubType__c,
               Name,
               Product2.Name,
               Product2.JSONAttribute__c,
               RecurringPrice__c,
               IsActive
            FROM
               PricebookEntry
            WHERE
               Pricebook2Id = : itemId AND (Product2.recordTypeId = null OR Product2.recordType.DeveloperName = 'Product')];
         }
         catch(Exception e)
         {
            throw e;
         }
      }
      return retval;
   }
}

Related Implementations

  • AccountTypeProductEligibilityImplementation

  • DefaultEligibilityOpenImplementation

  • EligibilityRulesFlowImplementation

  • FilterEligibilityImplementation

 
Loading
Salesforce Help | Article