Welcome to Zuora Product Documentation

Explore our rich library of product information

Sample scenario for LookupComponent

This task demonstrates how to use the LookupComponent within the PropertyComponent to display and manage the Contact type field.

This usage example uses the LookupComponent within the PropertyComponent to display the Contact type field.
  1. Build a field set
    1. Add the columns shown on lookup component pop-up dialog box from the pre-defined Contact field set.
    2. The Name field is required in the field set. If you use your own custom field set, the field set must contain the Name field.
  2. The Apex controller

    In your property component controller, put the field name and lookup component options instance into Map lookupFields.

    // Set up options for Sold To Contact lookup 
    fieldLookupComponentOptions optionsForSoldTo = new LookupComponentOptions();
    optionsForSoldTo.objectName = 'Contact';
    optionsForSoldTo.Id = 'SoldToContact';
    optionsForSoldTo.objectId = this.opp.Id;
    optionsForSoldTo.isEditMode = true;
    optionsForSoldTo.isRequired = true;
    optionsForSoldTo.lookupComponentControllerName = 'ContactLookupComponentController';
    optionsForSoldTo.recordTypeId = Contact.SObjectType.getDescribe().getRecordTypeInfosByName().get('Master').getRecordTypeId();
    optionsForSoldTo.popupWindowTitle = 'Sold To Contact Lookup';
    //Define default value for lookup field this way
    optionsForSoldTo.lookupFields = new Map<String, LookupComponentOptions> 
      {NamespaceUtil.zQuotesPrefix+'SoldToContact__c'=>optionsForSoldTo};

    If you are building your own custom lookup controller class that extends zqu.LookupComponentController, you must override the getAutoCompleteBaseSoql method to get the base soql for auto complete to work. For example:

    // Override the getAutoCompleteBaseSoql() method to get base soql for auto complete
    public override String getAutoCompleteBaseSoql() {
    return 'Select Id, Name From Contact';
    }
  3. The Apex page

    If you are using the LookupComponent in a PropertyComponent, you don't need to do anything on the Apex page.

    If you want to use the lookup component as a standalone component on your own page, include it on your page and set the options for it in your page controller as was done in Step 2.