Resuming a Workflow with a signal: how to set process data?

Options
basinilya
edited April 26, 2021 in Documentum #1

My workflow activity initiates a long asynchronous service call and completes. The next activity has a value in the field Trigger/"And when this signal arrives" .

After some time the remote service connects to my docbase and sends this signal.

Now, how to populate Process Data/Packages with the results of the service call?

I know the workitemId that called the service and I tried calling addPackage() on that workitem. However, the workitem is already completed and addPackage() fails with:

[DM_WORKFLOW_E_ACTION_NOT_ALLOWED]error: "This operation is not allowed when the state is 'finished' for workitem '4a01e2408000910d'


So I probably want to write directly to the workflow, but I can't find the method to add packages to a workflow.

IDfWorkflow has addPackage(), but it's intended for constructing a new workflow and expects the parameter startActivityName:


                workflow
                    .addPackage(
                        "Join",
                        "Input:0",
                        "optional_b",
                        "dm_document",
                        null,
                        false,
                        asSingletonList(new DfId("0901e2408014d74f")));

_

[DM_WORKFLOW_E_INVALID_ACTIVITY_TYPE]error: "The activity, Join, is not a start activity."

_

Tagged:

Comments

  • Is there a reason why you are not using Process Builder (or Workflow Manager) to configure this instead of trying to do this via low-level coding?

  • I don't see how it can help me.

  • Package is defined at the process template level (dm_process). Using GUI, you dont have to worry about whether the activities in the process has access to the package or not.

    Basically, what I am trying to say is that I can answer your low-level API question, since most of my workflow development experience has always been using the GUI as much as possible. The only time I have to do low level coding is when I have to call server method in the WF to do backend processing - I have never had to "code" the actual workflow itself.

  • So how do I do automatic things that take longer than the longest possible method timeout?

  • Instead of putting this in the middle of WF, I would re-design the workflow such that the service call trigger/initiate the WF. This is how we avoided timeout issues with long executing web service calls.

  • This makes sense. I'll try.

  • I think that you did the right thing by calling IDfWorkitem.addPackage, but you probably picked to wrong workitem. You should use the workitem that corresponds to the next activity which is triggered by the signal. I suppose you picked the workitem of the previous activity which performed the asynchronous call.

  • The next workitem doesn't exist yet. The dmi_package objects for the next activity are copied, but the workitem will be created only after I sent the signal.

  • Right, and after you send the signal, get the new workitem and add the package.

  • How do I do it before the next item does something or even completes?

  • You design the workflow. Make sure that activity is not automated otherwise it will indeed complete. It should be manual and you should complete it when you are ready to resume the workflow.

  • Easier to see this and understand the workflow design if you use GUI ?