2

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.

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • 1
    Did I get this right that you already have custom workflow component in place? – ᄂ ᄀ Jul 30 '18 at 06:35
  • A: Yes. And the question is "how can the custom component get before/after property values for an 'Update'"? user9628593 gave me an excellent suggestion. But there doesn't seem to be any way to pass before/after changes - or pass the OriginalObject - directly from the workflow subscription to the workflow. Without some "middle step". Like a custom CE Event handler that creates a CustomObject to pass the information. – paulsm4 Jul 30 '18 at 18:33
  • I don't think it is especially good suggestion since it is nothing more than accidental complexity. Your task should be tackled by creating a custom `EventAction` that will launch a required workflow instance. In that action you will be able to initialize it as you please, i.e. using data from the `OriginalObject` property. Alternatively, you can employ auditing to have update events persisted in the repository. But it could be too taxing for the system to have auditing enabled. – ᄂ ᄀ Jul 31 '18 at 09:39

2 Answers2

4

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.

Ricardo
  • 401
  • 3
  • 4
  • Perfect - thank you. The key point is that I *CANNOT* somehow communicate before/after values with just the workflow subscription. I *MUST* have a (e.g. Java) custom event handler for this to work. – paulsm4 Jul 30 '18 at 16:01
0
if(objEvent instanceof UpdateEvent) { try { String strModifiedProperties = ""; UpdateEvent updateEvent = (UpdateEvent) objEvent; StringList propertyNames = updateEvent.get_ModifiedProperties(); Iterator iterModifiedProps = propertyNames.iterator(); while(iterModifiedProps.hasNext()) { String modifiedProperty = (String) iterModifiedProps.next(); strModifiedProperties = strModifiedProperties+modifiedProperty+","; } strModifiedProperties = strModifiedProperties.substring(0, strModifiedProperties.lastIndexOf(",")); } catch (Exception e) { System.out.println("onEvent : Exception while executing UpdateEvent: "+e.getMessage()); } }
  • Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Feb 21 '22 at 10:30