Creating the object definition for the campaign element

Create a new object definition for the new campaign element to collect input from the Management Center user interface. When business users fill in data about the new campaign element in a marketing activity, the object definition persists the data in two tables: DMELEMENT and DMELEMENTNVP.

Before you begin

Review the following topics to ensure that you understand object definitions in Management Center and the mktFlowElementObjectDefinition class that you must extend:

For information about creating resource bundles for text strings, see Defining properties files and bundle keys for user interface text.

About this task

In the Marketing tool, each campaign element must have an object definition. Each object definition:
  • WebSphere Commerce Version 7.0.0.0Feature Pack 1is an extension class of the mktFlowElementObjectDefinition class
  • Introduced in Feature Pack 2extends the mktFlowElementObjectDefinition class

Procedure

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
  2. Create a directory to store your new campaign element object definition.
    You can store the file in a directory structure similar to the following example:
    • Feature Pack 1LOBTools/WebContent/WEB-INF/src/lzx/your_company_name/marketing/objectDefinitions/activityBuilder/
    • Introduced in Feature Pack 2LOBTools/WebContent/config/your_company_name/marketing/objectDefinitions/activityBuilder/
  3. Create a new file for the campaign element object definition:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1OpenLaszlo class file WebSphere Commerce Version 7.0.0.0Feature Pack 1Name the file using this syntax: campaign_element_nameFlowElementObjectDefinition.lzx; for example, CustomLevelOfSupportTargetFlowElementObjectDefinition.lzx.
    Introduced in Feature Pack 2Definition file Introduced in Feature Pack 2Name the file using this syntax: campaign_element_nameFlowElementObjectDefinition.def; for example, CustomLevelOfSupportTargetFlowElementObjectDefinition.def.
  4. Define the promotion element object definition.

    The following XML code is a simple example of an object definition for a new target. The example is split into four parts, and each part is explained in a substep after the table. Your object definition might require more attributes and child definitions. For a complete explanation of this class or definition and its capabilities, see the mktFlowElementObjectDefinition topic.

    Feature Pack 1
    Object definition example for a target
    1
    <class name="extCustomLevelOfSupportElementObject" extends="mktFlowElementObjectDefinition"
    	     objectType="customLevelOfSupportTarget"
         	displayName="${extMarketingResources.customLevelOfSupportName.string}"
         	headerIcon="customLevelOfSupportHeaderIcon"
         	flowIcon="customLevelOfSupportIcon"
         	paletteIcon="customLevelOfSupportPaletteIcon"
    	     propertiesClass="extCustomLevelOfSupportProperties"
    	     summaryClass="extCustomLevelOfSupportSummary"
    	     elemTemplateType="Target">
    
    2
        <mktFlowElementCreateService/>
        <mktFlowElementUpdateService/>
    
    3
        <dataset name="template">
            <elemTemplateName>customLevelOfSupportTarget</elemTemplateName>
            <supportLevel>gold</supportLevel>
        </dataset>		
    
    4
        <wcfPropertyDefinition propertyName="supportLevel" displayName="Support Level">
    	    <wcfPropertyValue displayName="Gold" value="gold"/>
    	    <wcfPropertyValue displayName="Silver" value="silver"/>
    	    <wcfPropertyValue displayName="Bronze" value="bronze"/>
        </wcfPropertyDefinition>
    </class
    Introduced in Feature Pack 2
    Object definition example for a target
    1
    <FlowElementObjectDefinition package="mkt"
            definitionName="extCustomLevelOfSupportElementObject"
            objectType="customLevelOfSupportTarget"
            displayName="${extMarketingResources.customLevelOfSupportName}"
            headerIcon="customLevelOfSupportHeaderIcon"
            flowIcon="customLevelOfSupportIcon"
            paletteIcon="customLevelOfSupportPaletteIcon"
            propertiesDefinitionName="extCustomLevelOfSupportProperties"
            summaryClass="extCustomLevelOfSupportSummary"
            elemTemplateType="Target">
    2
    <FlowElementCreateService package="mkt"/>
          <FlowElementUpdateService package="mkt"/>
    3
        <Xml name="template">
            <elemTemplateName>customLevelOfSupportTarget</elemTemplateName>
            <supportLevel>gold</supportLevel>
          </Xml>
    4
    <PropertyDefinition propertyName="supportLevel" displayName="Support Level">
             <PropertyValue displayName="Gold" value="gold"/>
             <PropertyValue displayName="Silver" value="silver"/>
             <PropertyValue displayName="Bronze" value="bronze"/>
          </PropertyDefinition>
      </FlowElementObjectDefinition>
    1. As per example section 1, specify the following attributes for the object definition:
      objectType
      A unique name for this campaign element object. By convention, this is typically the same name that you used for the associated campaign element template definition, which is stored as the NAME value in the DMELETEMPLATE table. However, if this campaign element object maps to multiple campaign element definitions, choose a descriptive value for this attribute.
      displayName
      The display text for the campaign element. You can either provide a static string, or provide a reference to a resource in your custom resource bundle, as shown in the example code. The format for this reference is:

      WebSphere Commerce Version 7.0.0.0Feature Pack 1${extcustom_resource_bundle_class_id.name_of_resource_bundle_key.string}

      Introduced in Feature Pack 2${extcustom_resource_bundle_id.name_of_resource_bundle_key.string}

      headerIcon
      The image resource for the campaign element that is displayed in the top-left corner of the properties view for the campaign element. To use the generic header icon supplied with Management Center, specify one of the following image names:
      • genericTriggerHeaderIcon
      • genericTargetHeaderIcon
      • genericActionHeaderIcon
      flowIcon
      The image resource for the campaign element that is displayed in the Activity Builder work area. To use the generic flow icon supplied with Management Center, specify one of the following image names:
      • genericTriggerIcon
      • genericTargetIcon
      • genericActionIcon
      paletteIcon
      The image resource for the campaign element that is displayed in the Activity Builder palette. To use the generic palette icon supplied with Management Center, specify one of the following image names:
      • genericTriggerPaletteIcon
      • genericTargetPaletteIcon
      • genericActionPaletteIcon
      WebSphere Commerce Version 7.0.0.0Feature Pack 1propertiesClass
      WebSphere Commerce Version 7.0.0.0Feature Pack 1(Optional) The name of the class to use for displaying the properties view of this campaign element object. If your campaign element requires input from a business user, you must create a custom properties view class for the user interface, which is covered in the procedure Creating the properties view for the campaign element. You can either give your custom properties view class a name now, or update this attribute later, after you have created the custom properties view class.
      Introduced in Feature Pack 2propertiesDefinitionName
      Introduced in Feature Pack 2(Optional) The name of the definition to use for displaying the properties view of this campaign element object. If your campaign element requires input from a business user, you must create a custom properties view definition for the user interface, which is covered in the procedure Creating the properties view for the campaign element. You can either give your custom properties view definition a name now, or update this attribute later, after you have created the custom properties view definition.
      summaryClass
      (Optional) The name of the class to use for displaying the summary of this campaign element object. The summary text is displayed in the Activity Builder work area below the campaign element icon. If your campaign element requires this summary text, you must create a custom summary class, which is covered in the procedure Creating the summary for the campaign element. You can either give your custom summary class a name now, or update this attribute later, after you have created the custom summary class.
      elemTemplateType
      The type of campaign element; the value can be Target, or Action, or Trigger.
    2. As per example section 2, add the following child service definitions:

      These services are used when business users create and update campaign elements using the Activity Builder, and might require additional attributes and child wcfServiceParam definitions, depending on the requirements of your campaign element.

      If your parameters refer to other service parameters, such as a category, then you require service parameter definitions like the following examples:

      WebSphere Commerce Version 7.0.0.0Feature Pack 1
      <mktFlowElementCreateService>
          <wcfServiceParam
              name = "PROPERTY_categoryIdList"
              objectPath = "ChildCatalogGroup/CatalogGroupAlias"
              propertyName = "catgroupId"
              optional = "false"/>
      </mktFlowElementCreateService>
      
      Introduced in Feature Pack 2
      <CreateService baseDefinitionName="mktFlowElementCreateService">
          <ServiceParam
              name = "PROPERTY_categoryIdList"
              objectPath = "ChildCatalogGroup/CatalogGroupAlias"
              propertyName = "catgroupId"
              optional = "false"/>
      </CreateService>
      WebSphere Commerce Version 7.0.0.0Feature Pack 1
      <mktFlowElementUpdateService>
          <wcfServiceParam
              name = "PROPERTY_categoryIdList"
              objectPath = "ChildCatalogGroup/CatalogGroupAlias"
              propertyName = "catgroupId"
              optional = "false"/>
      </mktFlowElementUpdateService>
      Introduced in Feature Pack 2
      <UpdateService baseDefinitionName="mktFlowElementUpdateService">
          <ServiceParam
              name = "PROPERTY_categoryIdList"
              objectPath = "ChildCatalogGroup/CatalogGroupAlias"
              propertyName = "catgroupId"
              optional = "false"/>
      </UpdateService>
    3. As per example section 3, if required:
      • WebSphere Commerce Version 7.0.0.0Feature Pack 1Declare a single instance of a dataset with the name template. You can use the template dataset to declare default values for the campaign element properties. The <dataset> element must have an <elemTemplateName> child element. The value of <elemTemplateName> must match a value in the NAME column of the DMELETEMPLATE table for this campaign element. In the example code, the dataset declares a default value of gold for the supportLevel property. You can also use the template dataset to declare child objects that can be instantiated within the new campaign element object. For more details on using a template dataset, see wcfObjectDefinition.
      • Introduced in Feature Pack 2Add an Xml element with the name attribute set to template. You can use the template to declare default values for the campaign element properties. The <Xml> element must have an <elemTemplateName> child element. The value of the <elemTemplateName> must match the value in the NAME column of the DMELETEMPLATE table for this campaign element. In the example code, the template declares a default value of gold for the supportLevel property. You can also use the template to declare child objects that will be instantiated within the new campaign element object. For more details on using a template, see wcfObjectDefinition.
    4. As per example section 4, if required, define the properties of the campaign element.
      See lzx/commerce/foundation/restricted/PropertyDefinition.lzx/wcfPropertyDefinition. In the example code, the campaign element object has only one property, supportLevel. More complex campaign elements can have multiple properties and child objects. At a minimum, declare wcfPropertyDefinition instancesIntroduced in Feature Pack 2 or property definitions for any variables the business user needs to provide that are defined in the campaign element template definition, that is, within the implementation definition and behavior rule definition in the template. Your campaign element might also require instances of:

      Consider using the object definition of an existing, similar campaign element as a reference for your new campaign element. The existing object definition files are stored here:

      WebSphere Commerce Version 7.0.0.0Feature Pack 1LOBTools/WebContent/WEB-INF/src/lzx/commerce/marketing/objectDefinitions/activityBuilder/

      Introduced in Feature Pack 2LOBTools/WebContent/config/commerce/marketing/objectDefinitions/activityBuilder/

  5. WebSphere Commerce Version 7.0.0.0Feature Pack 1Add a reference to the new object definition file in the MarketingExtensionsLibrary.lzx file.

    The file is stored at this path:

    LOBTools/WebContent/WEB-INF/src/lzx/commerce/marketing/

    The line of code that references the new object definition should look like the following example:

    <include href="../../your_company_name/marketing/objectDefinitions/activityBuilder/campaign_element_nameFlowElementObjectDefinition.lzx"/>

  6. Register the new object definition in its parent object definition:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1Open the LOBTools/WebContent/WEB-INF/src/lzx/commerce/marketing/objectDefinitions/activityBuilder/FlowPathElementObjectDefinition.lzx file WebSphere Commerce Version 7.0.0.0Feature Pack 1
    1. Locate the mktBaseFlowPathElementObject class.
    2. Within this class, create an instance of your new object definition as a child by inserting a line similar to the following example (see the line in bold font):
    3. <class name="mktBaseFlowPathElementObject"
      	extends="wcfChildObjectDefinition"
      	displayName="${mktMarketingResources.path.string}"
      	isBaseDefinition="true">
      
      	<!-- ... -->
      	<extCustomLevelOfSupportElementObject/>
      	<!-- ... -->
      </class>
    4. Save and close the file.
    Introduced in Feature Pack 2Open the LOBTools/WebContent/config/commerce/marketing/objectDefinitions/activityBuilder/FlowPathElementObjectDefinition.def file Introduced in Feature Pack 2
    1. Locate the mktBaseFlowPathElementObject definition.
    2. Within this definition, add your new object definition as a child by inserting a line similar to the following example (see the line in bold font):
    3. <ChildObjectDefinition definitionName="mktBaseFlowPathElementObject"
      	displayName="${mktMarketingResources.path}"
      	isBaseDefinition="true">
      
      	<!-- ... -->
      	<FlowElementObjectDefinition package="mkt"
      		baseDefinitionName="extCustomLevelOfSupportElementObject"/>
      	<!-- ... -->
      </ChildObjectDefinition>
    4. Save and close the file.