Configuring Subscription Events

You can define any event within the apps as subscribable. Users can then subscribe to that event, and when it occurs, they will receive a notification.

See Subscriptions to see how the user works with subscriptions. Subscribable events use the relationship hierarchy. If you define a subscribable event on a relationship, all children of that relationship inherit the subscribable event.

The examples in this task use the sample event shown in About Custom Subscriptions.

  1. Open the Run MQL window:
    1. From the compass, select Collaboration and Approvals.
    2. In the navigation pane, click Utilities > Run MQL.
    To run an MQL command, enter the command in the MQL Command box and click Run or press Enter.
  2. To set the context for the MQL session, run this command:

    set context user creator;

  3. To define the events menu, follow these steps:
    1. To determine if an event menu already exists for an object, run this command:

      print type <TYPENAME>;

      where <TYPENAME> is the name of the object involved in the event. For example:

      print type Decision;

      In the list of properties, check if the SubscriptionEventsMenu property has been defined. For a Decision, the property looks like this:

      property SubscriptionEventsMenu to menu APPDecisionEvents

      If the menu exists, you do not need to create an events menu. You can add your event command to the existing menu.

    2. To create the events menu, run this command:

      add menu <MENUNAME> description <DESCRIPTION>;

      where:

      • <MENUNAME> is the name of the menu. Use this naming convention:
        <APP><TYPENAME_OR_RELNAME>Events

        where:

        • <APP> is the abbreviation for that app (look at other menus used by the app to determine this value)
        • <TYPENAME_OR_RELNAME> name is the administrative object type or relationship

      • <DESCRIPTION> is a brief description of the menu

      For example:

      add menu APPDecisionEvents description "Events menu for Decisions";

  4. To define each event command, follow these steps:

    add command <COMMANDNAME> description <DESCRIPTION> setting <SETTINGNAME> <SETTINGVALUE>;

    where:

    • <COMMANDNAME> uses this format:
      <APP><TYPENAME_OR_RELNAME><EVENT>Event

      where:

      • <APP> from the table above
      • <TYPENAME_OR_RELNAME> is the name of the relationship on which the events are being defined
      • <EVENT> is the event that triggers the notification defined by this subscription

    • <DESCRIPTION> is a brief description of how the event occurs
    • <SETTINGNAME> and <SETTINGVALUE> are settings from this table:
      Setting Name Description Possible/Default Values
      Event Type The name of the event used as the value of the object's Event Type attribute.

      InstanceModify

      History Bit Same as the history events returned from the transaction trigger and is used to define the command name associated with a subscription event.

      modify

      create

      Global When true, the event is subscribable at the relationship level. The user is notified when that event occurs on any connection using this relationship. When false, the event is subscribable for a specific relationship connection.

      Custom functionality must be developed to use global subscriptions. For more information, see Legacy ENOVIA Web Apps Customization Guide.

      true

      false (default)

      Registered Suite The app the column belongs to. The system looks for files related to the column in the registered directory for that app, which is specified in emxSystem.properties.

      Based on the app name, the system passes the following parameters in the href URL:

      suiteKey

      emxSuiteDirectory

      StringResourceFileId

      The value cannot contain spaces, for example. Set the value to the suite name as defined in the key eServiceSuites.DisplayedSuites in emxSystem.properties. If the suite name starts with "eServiceSuite" you can skip this prefix and assign the remaining text to the setting.

    For example:

    add command APPDecisionAttachedEvent 
         description "When Decision is used in a Decision Relationship"
         setting "Event Type" "Decision Attached" 
         setting "Registered Suite" Components;

  5. To connect the event commands to the event menu, run this command:

    modify menu <MENUNAME> add command <COMMANDNAME>;

    where:

    • <MENUNAME> is the name of the menu defined above
    • <COMMANDNAME> is the name of the command defined above

    For example:

    modify menu APPDecisionEvents add command APPDecisionAttachedEvent ;

  6. To map the event menu to the object, run this command:

    modify type <NAME> property SubscriptionEventsMenu to menu <MENUNAME>;

    where:

    • <NAME> is the admin type
    • <MENUNAME> is the menu created above

    For example:

    modify type Decision property SubscriptionEventsMenu to menu APPDecisionEvents

    When a user chooses to subscribe to the object (a Decision), the subscribe dialog box is populated with the commands in the specified menu.
  7. To create the notification, run this command:

    add businessobject Notification <NAME> <REVISION> 
         policy "Business Rule"
         vault "eService Administration"
         "Body HTML" <HTML Code>
         "Body Text" <TEXT>
         "From Agent" <PERSON>
         "Registered Suite" <SUITE>
         "Static To List" emxSubscriptionUtil:getSubscribersList
         "Subject Text" <STRING>
         "URL Suffix" <SUFFIX>;

    where:

    • <NAME> is the name of the object. Use the name of the command created above.
    • <REVISION> is the revision level. use the relationship name and event type.

    The remainder of the command adds these attributes:

    AttributeDescriptionExample Value
    Body HTMLProperty in the string resources file that contains the message in HTML format.emxVPMCentral.Notification.PLMInstanceModify.Body.HTML
    Body TextProperty in the string resources file that contains the message in text format.emxVPMCentral.Notification.PLMInstanceModify.Body
    From AgentThe Person to show in the From field of the email message. If you use &USER, the notification is sent from the context user. $<person_UserAgent>

    &USER

    Registered SuiteThe app's suite name.VPMCentral
    Static To ListThe program:function that retrieves the notification's "to" list (the list of subscribers).JPO emxSubscriptionUtil:getSubscribersList
    Subject TextProperty in the string resources file that contains the text for the Subject line of the email message. emxVPMCentral.Notification. PLMInstanceModify.Subject
    URL SuffixURL parameter/values to add to the URL string in the email message.&mode=tree

    For example:

    add businessobject Notification APPDecisionAttachedEvent - 
         policy "Business Rule"
         vault "eService Administration"
         "Body HTML" emxCommonUtil:getNotificationHTML
         "Body Text" emxCommonUtil:getNotificationText
         "From Agent" ${USER}
         "Registered Suite" Components
         "Static To List" emxSubscriptionUtil:getSubscribersList
         "Subject Text" emxComponents.Notification.Event.Decision_Attached;

    You also need to define the string resources used by the notification. In the above example, the Subject Text defines a string resource. For more information, see Changing Onscreen Text and Other Strings.

  8. To define the trigger (eServices Trigger Program Parameters object), run this command:

    add businessobject "eService Trigger Program Parameters" <NAME> <REVISION>
         vault "eService Administration"
         "eService Method Name" <METHOD>
         "eService Program Name" <PROGRAM>
         "eService Sequence Number" <INTEGER>
         "eService Program Argument 1" ${RELID}
         "eService Program Argument 2" <EVENT>;

    where:

    • <NAME> use the same name as assigned to the command
    • <REVISION use the same revision assigned to the command
    • The remainder of the command adds these attributes:
      AttributeValue
      eService Method NameWhen defining a trigger for an object, use objectNotification. When defining a trigger for a relationship, use relationshipNotification.
      eService Program NameemxNotificationUtil
      eService Sequence Number101 (or any high number to ensure the notification follows any other actions defined for the event)
      eService Program Argument 1For an object-related event, use ${OBJECTID}. For an event for an object caused by a relationship, use $[FROMOBJECTID} or ${TOOBJECTID}, depending on which side of the relationship that triggered the event the object is attached to.

      For a relationship trigger, use ${RELID}.

      eService Program Argument 2Event Type, where the value is the Event Type defined when you created the command

    For example:

    add businessobject "eService Trigger Program Parameters" APPDecisionAttachedNotificationAction APPDecisionAttachedEvent
         vault "eService Administration"
         "eService Method Name" objectNotification
         "eService Program Name" emxNotificationUtil
         "eService Sequence Number" 101
         "eService Program Argument 1" ${FROMOBJECTID}
         "eService Program Argument 2" APPDecisionAttachedEvent; 

  9. To define an action trigger for the event, follow these steps:
    1. Print the details of the object or relationship to determine if an action trigger already exists. The sample in this task is an event that occurs when a Decision is attached to an object. The action trigger for the subscription needs to be on the relationship used to make that connection. For this example, you would run this command:

      print relationship Decision;

      Look for the line defining triggers. In this example:

      trigger CreateAction:emxTriggerManager(APPDecisionAttachedNotificationAction 
      APPAttachedToDecisionNotificationAction DomainAccessRelationshipToCreateAction 
      RelationshipAllCopyChildPOVCreateAction),
      DeleteAction:emxTriggerManager(DomainAccessRelationshipDeleteAction)

      This relationship includes several action triggers that run when the relationship is created (CreateAction), and one delete action trigger.

    2. To add the action trigger, run this command:

      modify <TYPE_OR_REL> <TYPENAME_OR_RELNAME> add trigger <EVENT_TYPE> action 
          eTriggerManager <TRIGGERNAME>;

      where:

      • <TYPE_OR_REL> is either type or relationship, depending on where you are adding the trigger
      • <TYPENAME_OR_RELNAME> is the name of type or relationship
      • <EVENT_TYPE> is the type of event that the user wants to be notified of. For a list of events, see MQL Command Reference: type Command.
      • <TRIGGERNAME> is the name of the eServices Trigger Program Parameters object that you created above.

      For example:

      modify relationship Decision add trigger connect action 
          eTriggerManager APPDecisionAttachedNotificationAction;

  10. To activate the notification and trigger objects, run these commands:

    modify businessobject Notification <NAME> <REVISION> current Active;
         
    modify businessobject "eService Trigger Program Parameters" <NAME> <REVISION> current Active;

    Use the exact names and revisions for these objects as defined above. For example:

    modify businessobject Notification APPDecisionAttachedEvent - current Active;
    
    modify businessobjects "eService Trigger Program Parameters" APPDecisionAttachedNotificationAction APPDecisionAttachedEvent
        current Active;