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
          ProductAvailabilityOpenInterface

          ProductAvailabilityOpenInterface

          The ProductAvailabilityOpenInterface displays product availability messages in the UI.

          Type

          Loosely typed

          Triggered When

          The ProductAvailabilityOpenInterface is triggered when presenting a list of products in the Opportunity Manager, Order Manager, Quote Manager, or Vlocity Cart.

          Called In

          The ProductAvailabilityOpenInterface is called in getAllAvailabilityProducts and getAvailableProducts. These methods return all available products associated with the price book.

          The ProductConfigurationController checks if the includeineligible custom setting is true. If True, the ProductConfigurationController calls the ProductListUtility.getAllEligibilityProducts method. The ProductListUtility.getAllEligibilityProducts method gets the implementation associated with the ProductAvailabilityOpenInterface and calls getAllAvailabilityProducts on the implementation.

          Note
          Note

          Availability is called with eligibility, which is why the ProductListUtility.getAllEligibilityProducts method is called.

          The following is the data flow for availability and eligibility:

          1. AdvProductSearchController

          2. ProductListUtility.getProducts

          3. ProductAvailabilityOpenInterface

          4. getAvailableProducts

          5. ProductEligibilityOpenInterface

          6. getEligibleProducts

          Signature

          Access

          Signature

          global

          Boolean invokeMethod(String methodName, Map input, Map output, Map options)

          Default Implementation

          The DefaultAvailabilityOpenImplementationDefaultAvailabilityOpenImplementation provides availability in a loosely typed interface. It returns the list of price book entry values that was passed in, using the parameter outputMap.

          Other Implementations

          The AvailabilityFlowOpenImplementationAvailabilityFlowOpenImplementation uses the Availability Rules flow, which evaluates defined availability rules. The method getAllAvailabilityProducts returns all products with reasons for availability or unavailability.

          Input Parameters

          methodName

          Required

          Type: String

          The name of the method to execute

          • getAllAvailabilityProducts returns available and unavailable Products in the Price Book with availability messages.

          • getAvailableProducts returns only available products with availability messages.

          input

          Required

          Type: Map<String, Object>

          The input map contains the following:

          • parentItem

            Type: sObject

            The parent context header item—Opportunity, Order, or Quote

          • pricebookEntryList

            Type: List<PricebookEntry>

            List of price book entries associated with the parent

          Output Parameters

          itemWrapperList

          Type: List<ItemWrapper>

          Wrapped Price Book Entry objects and availability messages. Each ItemWrapper will contain the following:

          • itemsObject: The Price Book Entry sObject

          • productId: The product ID associated with the price book entry

          • isQualified: A Boolean flag that indicates availability

          • errors: List of strings containing availability messages

          options

          Not currently used

          Sample Implementation

          global with sharing class SampleAvailabilityOpenImplementation implements vlocity_cmt.VlocityOpenInterface
          {
             global Boolean invokeMethod(string methodName, Map<string, object> inputMap, Map<string, object> outputMap, Map<string, object> options)
             {
                Boolean success = true;
                try
                {
                   if(methodName == 'getAllAvailabilityProducts')
                   {
                      doAvailability(inputMap, outputMap, true);
                   }
                   else if(methodName == 'getAvailableProducts')
                   {
                      doAvailability(inputMap, outputMap, false);
                   }
                }
                catch(Exception e)
                {
                   success = false;
                   outputMap.put('error', e.getMessage());
                   outputMap.put('itemWrapperList', new  List<vlocity_cmt.ItemWrapper>());
                }
                return success;
             }
             private void doAvailability(Map<string, object> inputMap, Map<string, object> outputMap, Boolean returnAll)
             {
                // Get the parent SObject from the input
                SObject item = (SObject)inputMap.get('parentItem');
                // Get the list of PriceBookEntry objects from the input
                List<PriceBookEntry> pricebookEntryList = (List<PricebookEntry>)inputMap.get('pricebookEntryList');
                // Wrap the list of price book entries with ItemWrapper objects and put in a map
                Map<Id, vlocity_cmt.ItemWrapper> pricebookIdToItemWrapper = new  Map<Id, vlocity_cmt.ItemWrapper>();
                for(integer index = 0; index < pricebookEntryList.size(); index++)
                {
                   pricebookIdToItemWrapper.put(pricebookEntryList[index].Id, new  vlocity_cmt.ItemWrapper(pricebookEntryList[index]));
                }
                try
                {
                   // Add logic here to operate on the pricebookIdToItemWrapper map determining availability for each one.
                   // You can also pass the pricebookIdToItemWrapper to a flow for more complex processing.
                   // Set the isQualified flag to true for available items and set the errors string for the availability message.
                   // Example: Available product
                   // pricebookIdToItemWrapper[key].isQualified = true;
                   // pricebookIdToItemWrapper[key].errors = new List<String> {'This product is available in the zip code'};
                   // Example: Not Available product
                   // pricebookIdToItemWrapper[key].isQualified = false;
                   // pricebookIdToItemWrapper[key].errors = new List<String> {'This product is not available in the zip code'};
                   List<vlocity_cmt.ItemWrapper> pbWrappers = pricebookIdToItemWrapper.values();
                   List<vlocity_cmt.ItemWrapper> result;
                   // For get getAllAvailabilityProducts, return the full list of ItemWrappers
                   if(returnAll)
                   {
                      result = new  List<vlocity_cmt.ItemWrapper>(pbWrappers);
                   }
                   // For getAvailableProducts, only return ItemWrappers where isQualified = true; i.e available ones
                   else
                   {
                      result = new  List<vlocity_cmt.ItemWrapper>();
                      for(Integer index = 0; index < pbWrappers.size(); index++)
                      {
                         if(pbWrappers[index].isQualified == false)
                         {
                            continue;
                         }
                         result.add(pbWrappers[index]);
                      }
                   }
                   // return the list of ItemWrappers in the output map
                   outputMap.put('itemWrapperList', result);
                }
                catch(System.FlowException e)
                {
                   outputMap.put('error', e.getMessage());
                   outputMap.put('itemWrapperList', new  List<vlocity_cmt.ItemWrapper>());
                }
             }
          }
           
          Loading
          Salesforce Help | Article