filenet-p8filenet-content-enginefilenet-cpe

CE Update Event: any way to pass before/after property values to a workflow?


I've configured a FileNet workflow subscription on Add, Update and Delete events. The workflow calls a Java component to send a notification message (to a third party).

We would like to see "before" and "after" property values in the notification message for "Update" events.

The "Event" object that triggers the subscription has a "Modified Properties" member, so I was hoping I could just create a corresponding "ModifiedProperties" string array in the workflow, and have the subscription map "Update.ModifiedProperties = ModifiedProperties". Unfortunately, the Event's "ModifiedProperties" only gives the NEW value, not the "before" value. <= So I don't see any way to get "before/after" values directly from the subscription...

It looks like the "UpdateEvent" object also has an "OriginalObject" member ... and I might be able to use the Java API to get the "before" value from the OriginalObject.

Q: Does this sound plausible method for getting the before/after document property values?

Q: Any ideas how to pass the "OriginalObject" object from the subscription to the workflow, so the Java component can use it?

The target platform is P8 5.2.1; I'm developing on P8 5.5.


Solution

  • You are right, the only way to the original values is through the OriginalObject object. And the quickest way to get data to a workflow is using a subscribable object.

    Therefore, a solution to your problem is to define a custom object containing the properties describing the new and the old property values. You create this custom object in a custom event handler triggered on an update event from the document. Here you can populate the properties of the custom object using the original object:

    Document document = (Document) event.get_OriginalObject();;
    Iterator<?> iterator = event.get_ModifiedProperties().iterator();
    while (iterator.hasNext()) {
        String modifiedProperty = (String) iterator.next();
    
        // TODO: Fetch the values from the original object 
        // and set them on the custom object. The details depend
        // on the data structure you choose.
    }
    

    Next you create a Workflow subscription triggered on the creation of the custom object. You can map the properties of your custom object to the data fields of your workflow. In the workflow that is started you can define an attachment and specify that the custom object is the initiating attachment. Using the CE_Operation queue methods you can now and delete the custom object when your processing is finished.