Knowledge Center

Knowledge Center > Zuora CPQ > Zuora CPQ Development Resources > Zuora CPQ Component Library > Zuora CPQ Global Components > Lookup Component

Lookup Component

The LookupComponent performs a lookup and display of reference fields in a pop-up dialog box. The component supports the following features:

  • ListComponent: Configure the columns displayed in the pop-up dialog box. 
    When configuring the list columns from a field set, make sure the field set includes the Name field (or the Full Name field for Contacts). The Name field is used in the pop-up dialog box as the link for setting a value for the lookup component. Otherwise, a system error is thrown when you open up the pop-up dialog box.
  • Custom field sets: Create your own field set and use it to show all the fields needed on a pop-up dialog box.
    To assign a field set in the pop-up dialog box, add the field set from the Lookup View Type in the Layout Configuration Settings.
  • Auto-complete: Set values directly by the auto-complete feature if you don't want to open up the pop-up dialog box and choose a value.

You can use the LookupComponent  within the PropertyComponent or as a standalone component.  To embed the LookupComponent within the PropertyComponent, put the field name and lookup component options instance into lookupFields, an attribute of PropertyComponentOptions.

The LookupComponent is available in the Versions 5.100 and later of Zuora Quotes.

The LookupComponent consists of:

  • LookupComponent.component: The Visualforce UI component
  • LookupComponentController.class: The Apex controller class for the LookupComponent UI component
  • LookupComponentOptions.class: The Apex class that stores the configuration options specified by the developer and used by the controller to render the component
  • LookupComponentPopupWindow.page: The Apex page that displays a list of all available records which can be selected. The list is rendered by ListComponent which can be configured from fieldSet.
  • LookupComponentPopupWindowController.class: The Apex controller class for the LookupComponent popup window

LookupComponent Component

LookupComponent Attributes

The LookupComponent has the following attribues. 

Attribute  Type Description
id String An identifier that allows the component to be referenced by other components in the page
isRequired Boolean This attribute is only used when the lookup component is custom rendering
options LookupComponentOptions

The configuration options of the lookup component.  See the Component Options section below for option details.

rendered Boolean Specifies whether the component is rendered on the page

LookupComponetOptions Class

LookupComponentOptions Properties

The LookupComponent can be configured by constructing an instance of the LookupComponentOptions. The LookupComponentOptions has the following properties.

 Property  Type  Required?  Description
Id String  Yes The unique id of the lookup component.
isEditMode Boolean  No The filed is editable if set isEditMode to true. Otherwise, the field cannot be edited. Default is false.
isRequired Boolean  No A red bar will be displayed besides the field if isRequired is set to true. Default is false.
lookupComponentControllerName String  Yes The name of controller which should extend the LookupComponentController class
lookupController LookupComponentController  No The controller will be used to get options information of lookup component
objectName String  Yes The name of object which the lookup field belongs to.
recordTypeId String  Yes The record type id of the object
targetId  String  No You can use this field to set the default value for the component, you must set both targetId and targetName (displayed on ui side) together.
targetName  String  No You can use this field to set the default value for the component, you must set both targetId and targetName (displayed on ui side) together.

Sample Scenario for LookupComponent

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.

Last modified

Tags

This page has no custom tags.

Classifications

(not set)