Integrate a Change Notification Trigger with an Existing Trigger - Precisely_EnterWorks - EnterWorks - 11.0

EnterWorks Guide

Product type
Software
Portfolio
Verify
Product family
EnterWorks
Product
Precisely EnterWorks
Precisely EnterWorks > EnterWorks
Version
11.0
Language
English
Product name
Precisely EnterWorks
Title
EnterWorks Guide
Copyright
2024
First publish date
2007
Last updated
2025-01-07
Published on
2025-01-07T07:44:20.997352
If a repository already has a trigger defined for it, to configure the repository to use Change Notification, update the existing trigger to call the Change Notification trigger as a final step before it saves any updates to the record the existing trigger is processing.
Warning: Do not configure a repository to directly invoke more than one trigger because it may cause multiple versions of records to be created each time an attribute value is edited.

To integrate the Change Notification Trigger into an existing trigger:

  1. Edit the repository's trigger properties:
    1. Log into the Classic UI.
    2. Open the Feature bar, open the folder holding the repository, select the repository, select Edit, and select Trigger Properties.
    3. Configure the existing trigger to pass the DB session to the trigger by setting the External Handler PassIn DBSession Indicator property to true.
  2. Edit the source file for the existing trigger:
    1. Make sure the doWork() method has the following signature:
      public void doWork(String repositoryName, long itemId, int action, ItemObject currentItem, 
      	List diffList, org.hibernate.Session hibernateSession, Connection conn)
      	throws Exception
    2. Define a BsessionEpimHelper instance with the following code:
      CustomRepositoryItem itemData = (CustomRepositoryItem)currentItem;
      // Change the session to admin user
      Bsession bSession = EpimCustomHelper.getAdminBsession();
      temData.setCurSession(bSession);
      HashMap<String, String> itemChanges = new HashMap<String, String>();
      
      // Create session helper using existing session and DB connection
      BsessionEpimHelper bsessionEpimHelper = BsessionEpimHelper.getInstance(bSession, conn, hibernateSession);
      
      // Retrieves all changes including to non-default languages in multi-language attributes:
      HashMap diffMap = ChangeNotificationTrigger.getCurDiffMap(diffList, itemData );
      Note: The statement Bsession bSession = EpimCustomHelper.getAdminBsession(); changes the current session to the admin user to ensure attribute security does not interfere with trigger operations.
    3. After the existing New/Modify processing, add the following statements:
      // Honor any change notifications
      itemChanges.putAll(ChangeNotificationTrigger.processChangeNotifications(repositoryName,
      	itemId, itemData, action, bsessionEpimHelper, diffMap, itemChanges, null));
      
      // Save any changes
      if (itemChanges.size() > 0) {
      	if (debugEnabled) appLogger.severe( "AutoCalculateTrigger.doWork: saving changes: " + itemChanges);
       	itemData.updateItemDataByFormatAttrHash(itemChanges, false);
      }
    4. Recompile the trigger source file and re-deploy the .jar file containing it.
  3. Repeat the above steps for each existing trigger.