Skip to main content

Allowed Records Plugin Example 1


Allowed Records Plugin Example 1

This article describes the process of creating a sample custom Allowed Records Plugin on the QuickList component. The sample plugin is applied to a Guided Selling Step to display product rate plans only offered to partners in the Guided Product Selector. The plugin uses a custom field on the ZProduct object to filter the product rate plans.

Implement an Allowed Records Plugin​

Follow the steps given in this section to set up the product catalog, create a plugin, and test the plugin.

To set up the products in Zuora Product Catalog and in Zuora Quotes:

  1. Create a custom field on the Product object in Zuora and on the ZProduct object in Zuora Quotes as below:
    • Custom field name: ForPartnersOnly
    • Field type: Picklist
    • Picklist values: true, false
  2. Create or edit the products in the Zuora product catalog, and assign the field values for the new custom field.
  3. Synchronize the product catalog to Zuora Quotes.

To create the example Guided Product Steps:

  1. In Zuora Quotes, navigate to Zuora Config > Guided Product Selectors.
  2. Create a Guided Selling Flow, Partner Products Flow. Save the flow.
  3. Create a Guided Selling Step, AddPartnerProducts. Save the step.

To create the example plugin and register it:

  1. Create a new class, AllowedRatePlans, using the code below.
  2. Navigate to Zuora Config > Component Registration.
  3. Click Edit for the QuickList component with the name, AddPartnerProducts.
  4. In the Component Plugins section, for the Allowed Records Plugin type, specify AllowedRatePlans in the Class Name field.
  5. Click Update.
global class AllowedRatePlans implements 
   zqu.QuickListController.IAllowedRecordPlugin {    
   global Set<Id> getAllowedRecordIds(Map<Object, Object> contextIds, Map<String, String> pluginParams) {
      Id quoteId;              
      // Get the quote id from the contextIds input key-value pair.       
      for (Object k : contextIds.keySet()) {          
         if (((String) k).equalsIgnoreCase('Quote')) quoteId = (Id) contextIds.get(k);       
      Set<Id> allowedIds = new Set<Id>();              
      // Retrieve the current quote       
      zqu__Quote__c q = [SELECT Id, zqu__status__c FROM zqu__Quote__c WHERE Id = :quoteId];            
      // If the quote is not for New Subscription, show all product rate plans.       
      If (q.zqu__status__c <> 'New') return allowedIds;       
      List<zqu__ProductRatePlan__c> ratePlans = [SELECT Id, zqu__ZProduct__r.ForPartnersOnly__c FROM zqu__ProductRatePlan__c WHERE zqu__Deleted__c = false];            
      // Filter down the list of product rate plans for the product rate plans for partners       
      for (zqu__ProductRatePlan__c rp : ratePlans) {         
         if (rp.zqu__ZProduct__r.ForPartnersOnly__c == 'true') allowedIds.add(rp.Id);       
      return allowedIds;    

To test the new plugin:

  1. Create a quote for New Subscription.
  2. When you get to the Choose Product and Charges step, click the Partner Product Selectors flow.
  3. Click the AddPartnerProducts step, and only the product rate plans that you marked in Step 2 will appear in the product and rate plan list.