Loading
Get Started with Communications, Media, and Energy & Utilities (CME)...
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          ProductValidationInterface

          ProductValidationInterface

          The ProductValidationInterface implements compatibility rules, also known as configuration rules or validation rules. Compatibility rules specify the relationships between products. For example, one product could require, recommend, or exclude another product. The ProductValidationInterface validates the compatibility of the products in an opportunity, order, or quote. For more information about compatibility rules, see Compatibility RulesCompatibility Rules.

          Type

          Strongly typed

          Triggered When

          The ProductValidationInterface is typically triggered when a product is added to, modified in, or deleted from an opportunity, order, or quote.

          Called In

          The ItemListService class calls the ProductValidationInterface. The ItemListService class is responsible for a variety of line item operations, such as renumbering and validation.

          Signature

          Access

          Signature

          global

          static void validateLineItems(List itemsList)

          Default Implementation

          The DefaultProductValidationImplementationDefaultProductValidationImplementation is nonoperative. It returns the input as output without modification.

          Other Implementations

          • The ProductRelationshipValidationImplProductRelationshipValidationImpl (deprecated) runs product relationships directly, bypassing compatibility rules. The ProductRelationshipValidationImpl supports soft actions only—requires and excludes.

          • The ValidationRulesFlowImplementationValidationRulesFlowImplementation runs the active compatibility rules that are defined in the Validation Rules flow. It is an unmanaged implementation.

          • The ValidationRulesImplementationValidationRulesImplementation runs all active compatibility rules.

          Input Parameters

          itemsList

          Required

          Type: List<ItemWrapper>

          List of items to validate

          Output Parameters

          None

          Sample Implementation

          Note
          Note

          The following code does not include a namespace. You must change any referenced package component to refer to the appropriate namespace.

          global abstract class SampleProductValidationImplementation implements GlobalInterfaces.ProductValidationInterface
          {
             global static void validateLineItems(List<ItemWrapper> itemsList)
             {
                string objectName = string.valueOf(itemsList[0].itemSObject.getSObjectType());
                List<Id> ruleIds = new  List<Id>();
                List<SObject> itemList = new  List<SObject>();
                Map<Id, ItemWrapper> masterObjectIdToItemWrapper = new  Map<Id, ItemWrapper>();
                for(Rule__c rule: [SELECT
                   Id
                FROM
                   Rule__c
                WHERE
                   Type__c = 'Configuration' AND ObjectName__c = : objectName AND isActive__c = true])
                {
                   ruleIds.add(rule.Id);
                }
                for(ItemWrapper item: itemsList)
                {
                   itemList.add(item.itemSObject);
                   masterObjectIdToItemWrapper.put(item.itemSObject.Id, item);
                }
                Map<string, object> input = new  Map<string, object>();
                Map<string, object> output = new  Map<string, object>();
                input.put('ruleIdentifierType', 'Id');
                input.put('ruleIdentifiersList', ruleIds);
                FlowStaticMap.flowMap.put('itemList', itemList);
                FlowStaticMap.flowMap.put('masterObjectIdToItemWrapper', masterObjectIdToItemWrapper);
                input.put('isTriggeredByFlow', false);
                input.put('flowMap', FlowStaticMap.flowMap);
                RuleSupport ruleSupport = new  RuleSupport();
                RuleSupport.invokeMethod('executeRules', input, output, null);
             }
          }
           
          Loading
          Salesforce Help | Article