HCL Commerce Enterprise

Creating the summary for the price rule element

If you want to display summary text below the price rule element in the Price Rule Builder work area, create a new extension for this summary. In the Price Rule Builder, business users can read the summary text to quickly understand how an element is being used in a price rule.

About this task

This is an example of the summary for a condition as it would display to a business user in the Price Rule Builder work area; the summary is the text Customer registered before January 31, 2010:
Example of a price rule element summary

Typically, summary text can be either static text or a combination of static and dynamic text. In the previous example, all the text is static except for the actual date. This date changes dynamically depending on the date the business user specifies in the properties of the condition. You can review additional examples of summaries by looking at other price rule conditions and actions in Management Center.

Consider using the summary of an existing file, similar price rule element as a starting point for your new price rule element. The existing summary files are stored here:

LOBTools/WebContent/WEB-INF/src/xml/commerce/price/restricted/propertiesViews/priceRuleBuilder/

Procedure

  1. Open HCL Commerce Developer and switch to the Enterprise Explorer view.
  2. Create a directory to store your new summary file.
    Use a directory structure similar to the following example:

    LOBTools/WebContent/WEB-INF/src/xml/your_company_name/price/propertiesViews/priceRuleBuilder/

  3. Create an XML file with this syntax: pricerule_element_nameSummary.xml, for example, RegistrationTimeConditionSummary.xml.
  4. Define the new summary.
    Here is the code that produces the summary class in the previous example, based on the default DateConditionFlowElementSummary.xml file:
    <Definitions>
    	<FlowElementSummary classDefinition="true" definitionName="cmc/price/RegistrationTimeConditionElementSummary">
    		<dependency localName="priceResources" moduleName="cmc/price/PriceResources"/>
    		<dependency localName="DateUtil" moduleName="cmc/foundation/DateUtil"/>
    		<dependency localName="PreferenceManager" moduleName="cmc/shell/PreferenceManager"/>
    		<FlowSummaryParam name="startDate" propertyName="startDate"/>
    		<FlowSummaryParam name="endDate" propertyName="endDate"/>
    		
    		<!--- @keywords private -->
    		<handler name="oninit">
    			<![CDATA[
    			this.updateSummaryDel.connect(priceResources.Singleton.startDate, "onstring");
    			this.updateSummaryDel.connect(priceResources.Singleton.endDate, "onstring");
    			this.updateSummaryDel.connect(PreferenceManager.Singleton, "preferenceChanged");
    			]]>
    		</handler>
    
    		<method args="e" name="updateSummary">
    			<![CDATA[
    			if (typeof(e) == "undefined") e = null;
    			var summaryText = "";
    			var tooltipText = "";
    			var startDate = this.resolvedParams.startDate;
    			var endDate = this.resolvedParams.endDate;
    			var sDate = DateUtil.Singleton.parse(startDate, DateUtil.Singleton.DATE_TIME_FORMAT);
    			startDate = DateUtil.Singleton.formatUI(sDate, DateUtil.Singleton.UI_DATE_TIME_FORMAT);
    			var eDate = DateUtil.Singleton.parse(endDate, DateUtil.Singleton.DATE_TIME_FORMAT);
    			endDate = DateUtil.Singleton.formatUI(eDate, DateUtil.Singleton.UI_DATE_TIME_FORMAT);
    			if (startDate != "") {
    				summaryText = priceResources.Singleton.replaceValues("summary_startDate", [startDate]);
    				tooltipText = priceResources.Singleton.replaceValues("summary_startDate", [startDate]);
    			}
    			if (endDate != "") {
    				summaryText += ", " + priceResources.Singleton.replaceValues("summary_endDate", [endDate]);
    				tooltipText += ", " + priceResources.Singleton.replaceValues("summary_endDate", [endDate]);
    			}
    			this.setSummaryText(summaryText);
    			this.setTooltipText(tooltipText);
    			]]>
    		</method>
    		
    	</FlowElementSummary>
    </Definitions>
    Where:
    • The updateSummary method sets the summary text for the price rule element.
    • The updateSummary method must call the setSummaryText method with the summary text.
  5. Register this new summary as an object definition.

    Create a RegistrationTimeFlowElementObjectDefinition.xml file similar to the object definition files in LOBTools/WebContent/WEB-INF/src/xml/commerce/price/objectDefinitions/priceRuleBuilder/