Develop > Presentation layer > Customize marketing > Marketing customization: Management Center > Customizing triggers, targets, and actions > Add a new trigger, target or action
Create the object definition for the campaign element
Create a new OpenLaszlo 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 extend:
For information about creating resource bundles for text strings, see Define properties files and bundle keys for user interface text.
In the Marketing tool, each campaign element must have an object definition. Each object definition is an extension class of the mktFlowElementObjectDefinition class.
Procedure
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- Create a directory to store the new campaign element object definition. Use a directory structure similar to the following example:
LOBTools/WebContent/WEB-INF/src/lzx/your_company_name/marketing/objectDefinitions/activityBuilder/
- Create an OpenLaszlo class file for the campaign element object definition. Name the file using this syntax: campaign_element_nameFlowElementObjectDefinition.lzx; for example, CustomLevelOfSupportTargetFlowElementObjectDefinition.lzx.
- 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 and its capabilities, see the mktFlowElementObjectDefinition topic.
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
- As per example section 1 , specify the following attributes for the object definition:
- objectType
- A unique name for this campaign element object. Use the same name that you used for the associated campaign element template definition, which is stored as the NAME value in the DMELETEMPLATE table.
- displayName
- The display text for the campaign element. You can either provide a static string, or provide a reference to a resource in the custom resource bundle, as shown in the example code. The format for this reference is:
${extcustom_resource_bundle_class_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
- propertiesClass
- (Optional) The name of the class to use for displaying the properties view of this campaign element object. If the campaign element requires input from a business user, create a custom properties view class for the user interface, which is covered in the procedure Create the properties view for the campaign element. You can either give the custom properties view class a name now, or update this attribute later, after you have created the custom properties view class.
- 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, create a custom summary class, which is covered in the procedure Create the summary for the campaign element. You can either give the 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.
- 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 the campaign element.
If the parameters refer to other service parameters, such as a category, then you require service parameter definitions like the following examples:
<mktFlowElementCreateService> <wcfServiceParam name = "PROPERTY_categoryIdList" objectPath = "ChildCatalogGroup/CatalogGroupAlias" propertyName = "catgroupId" optional = "false"/> </mktFlowElementCreateService>
<mktFlowElementUpdateService> <wcfServiceParam name = "PROPERTY_categoryIdList" objectPath = "ChildCatalogGroup/CatalogGroupAlias" propertyName = "catgroupId" optional = "false"/> </mktFlowElementUpdateService>
- As per example section 3 , if required, declare 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 the 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.
- As per example section 4 , if required, define the properties of the campaign element. See 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 instances 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:
- wcfReferenceObjectDefinition
- wcfChildObjectDefinition
- wcfnameValidator (see the subclasses of wcfValidator that start with wcf)
Consider using the object definition of an existing, similar campaign element as a reference for the new campaign element. The existing object definition files are stored here:
LOBTools/WebContent/WEB-INF/src/lzx/commerce/marketing/objectDefinitions/activityBuilder/
- Add 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"/>
- Register the new object definition in its parent object definition:
- Open the FlowPathElementObjectDefinition.lzx file at this path:
/LOBTools/WebContent/WEB-INF/src/lzx/commerce/marketing/objectDefinitions/activityBuilder/
- Locate the mktBaseFlowPathElementObject class.
- Within this class, create an instance of the new object definition as a child by inserting a line similar to the following example (see the line in bold font):
<class name="mktBaseFlowPathElementObject" extends="wcfChildObjectDefinition" displayName="${mktMarketingResources.path.string}" isBaseDefinition="true"> <!-- ... --> <extCustomLevelOfSupportElementObject/> <!-- ... --> </class>
- Save and close the file.
Previous topic: Define icons to represent the campaign element
Next topic: Create the properties view for the campaign element
Related tasks
Add a new library to the Management Center
Related reference