Develop > Presentation layer > Customize marketing > Marketing customization: Management Center > Customizing triggers, targets, and actions > Add a new trigger, target or action


Create the campaign element task command

Create a new task command interface and its associated implementation class for the new campaign element. The task command performs the work for the campaign element, and it can also validate parameters if required.


Before you begin

Review the following topics to ensure that you understand task commands for campaign elements, as well as the relevant class and interface:

The campaign element task command must be a class that implements the MarketingCampaignElementTaskCmd interface and should extend from the MarketingCampaignElementTaskCmdImpl class.


Procedure

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.

  2. Create a package for the task command files:

    1. Navigate to WebSphereCommerceServerExtensionsLogic > src.

    2. Right-click the src folder; then click New > Package.

    3. In the Name field, type:

      com.your_company_name.marketing.commands.elements

    4. Click Finish.

  3. In the new package, create a new interface class for your campaign element task command that extends from the MarketingCampaignElementTaskCmd interface. Give the class the name that you specified in the implementation definition, for example, CustomLevelOfSupportTargetTaskCmd.

    Here is an example of a task command for a target that targets customers who have paid for a specific level of support:

    public interface CustomLevelOfSupportTargetTaskCmd extends MarketingCampaignElementTaskCmd {
    
    public final static String defaultCommandClassName =
    CustomLevelOfSupportTargetTaskCmdImpl.class.getName(); 
    }
    

  4. In the new package, create a task command implementation that extends from MarketingCampaignElementTaskCmdImpl class. Give the class a name that uses this syntax: campaign_element_nameTaskCmdImpl; for example, CustomLevelOfSupportTargetTaskCmdImpl.

    • For targets and actions, this task command implementation must implement the method performExecute. The task command implementation can also implement the method validateParameters to validate that the element has all the required user interface parameters.

    • For triggers, this task command implementation can implement either of the following methods, if required:

      • forwardTriggersForProcessing method: If the trigger is a daily check trigger, this method finds all the customers who meet the trigger criteria and then forwards the trigger for each customer.

      • validateParameters method: this method validates that the element has all the required user interface parameters.

    As a starting point, review the sample that is relevant to your customization:

  5. For any server-side error messages in the task command, create a new message key class:

    1. Navigate to WebSphereCommerceServerExtensionsLogic > src.

    2. Right-click the src folder; then click New > Package.

    3. In the Name field, type:

      com.your_company_name.marketing.logging

    4. Click Finish.

    5. In the new package, create a new class file to contain the message keys, for example, CustomMarketingMessageKeys.java. The following is an example of this type of class; the example contains message keys for the four sample campaign elements linked from the previous step:

      package com.mycompany.commerce.marketing.logging; 
      public class CustomMarketingMessageKeys {
      
       public final static String _APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_MISSING = "_APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_MISSING";  public final static String _APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_INVALID = "_APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_INVALID";  public final static String _APP_ACTIVITY_GIFT_REGISTRY_MISSING_NUMBER_OF_DAYS = "_APP_ACTIVITY_GIFT_REGISTRY_MISSING_NUMBER_OF_DAYS";  public final static String _APP_ACTIVITY_LEVEL_OF_SUPPORT_TYPE_IS_MISSING = "_APP_ACTIVITY_LEVEL_OF_SUPPORT_TYPE_IS_MISSING";  public final static String _APP_ACTIVITY_SEND_CATALOG_NAME_IS_MISSING = "_APP_ACTIVITY_SEND_CATALOG_NAME_IS_MISSING"; }
      

    6. Save the class file.

  6. Create a properties file to define the server-side error message text:

    1. Navigate to WebSphereCommerceServerExtensionsLogic > src.

    2. Right-click the src folder; then click New > Package.

    3. In the Name field, type:

      com.your_company_name.marketing.logging.properties

    4. Click Finish.

    5. In the new package, create a properties file to define the message text, for example, WcMarketingMessages.properties. The following is an example properties file; the example contains message text for the four sample campaign elements:

      _APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_MISSING=Specify a value for the Event type field.
      _APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_INVALID=The value in the Event type is not valid.
      _APP_ACTIVITY_GIFT_REGISTRY_MISSING_NUMBER_OF_DAYS=Specify a value for the Number of days field.
      _APP_ACTIVITY_LEVEL_OF_SUPPORT_TYPE_IS_MISSING=Specify a value for the Level of support field.
      _APP_ACTIVITY_SEND_CATALOG_NAME_IS_MISSING=Specify a value for the Catalog name field.
      

    6. Save the properties file.


Previous topic: Register controller command names to match in a behavior rule


Next topic: Inform the marketing services of an external event for a trigger or target


Related concepts

Marketing activity data storage and process flow


+

Search Tips   |   Advanced Search