Example - adding a search attribute

You may want to enable users to search the child price lists of a master price list.

About this task

In such a scenario, you can add the master price list ID attribute to the list of advanced price list search attributes. Because master price list IDs are string values, you can allow the query types, starts with or is, and use a text box as the input control.

To add the master price list ID as a search criteria:

Procedure

  1. Create the Pricelist.xml file in the <install_dir>/extensions/sbc/webpages/sbc/metadata/advancedsearch folder if the file does not exist in the folder. Ensure that the root element of the XML is Attributes.
  2. Create an Attribute element as a child element of the Attributes root element.
  3. Set the value of the Action XML attributes to ADD.
  4. Set the value of the Name XML attribute to PricelistName in the Attribute element. This is because the XML attribute that is set with the master price list ID in the input XML is PricelistName.
  5. Set the value of the XPath XML attribute to PricelistHeader\InheritFromPricelistHeader in the Attribute element. This is because the XML path of the PricelistName attribute for the master price list ID is PricelistHeader\InheritFromPricelistHeader.
  6. To define the user interface (UI) label in the search attribute drop-down list, set the DisplayName XML attribute to any key. Ensure that you add a bundle entry as the key for this attribute.
  7. To use a text field for the attribute, set the xtype XML attribute to xadvancedtextcontrol.
  8. Create an element, Configuration, as the child element of the Attribute element.
  9. Create an element, UIControlConfiguration, as the child element of the Configuration element.
  10. To use only a few string query types, create the element, StringQueryTypes, as the child element of the Attribute element.
  11. To support the is and starts with query types, perform the following steps:
    1. Add the QueryType elements with the value of the QueryType XML attribute as EQ and FLIKE.
    2. To customize the query type description, set the value of the QueryTypeDesc XML attribute to the correct bundle key.

    The search attribute is added.

    Following is the newly added attribute element for the master price list ID field:
    <Attribute Action="ADD" Name="PricelistName" DisplayName="b_Price_List_Name" 
    XPath="PricelistHeader/InheritFromPricelistHeader"> 
      <Configuration> 
        <UIControlConfiguration xtype="xadvancedtextcontrol"/> 
      </Configuration> 
      <StringQueryTypes> 
        <QueryType QueryType="EQ" QueryTypeDesc="is"/> 
        <QueryType QueryType="FLIKE"/> 
      </StringQueryTypes> 
    </Attribute>