Skip to main content

How to invite/get all users who can approve a document

For example, you have Transition A -> B and you need to notify users which can approve (or reject) a document in Activity B. You have two options to do that.

1st option:

To notify users who can do something with your document in Activity B. You need to put a notification code to Activity B. Use Code Actions or IWorkflowActionProvider to do that. When you execute a transition from A to B, the implementation of Activity B will be executed.

2nd option:

You can write code that determines and notifies respective users in ProcessStatusChanged or ProcessActivityChanged (in versions >= 1.5.5) event handlers.

You can take next user's ID in the following way:

In versions <= 1.5.4:

var activity = processInstance.ExecutedActivity; // it will be Activity B
var usersIds = runtime.GetAllActorsForAllCommandTransitions(processInstance.ProcessId, true, activity.Name);
// or you can use GetAllActorsForDirectCommandTransitions

In versions >= 1.5.5:

var usersIds = runtime.GetAllActorsForCommandTransitions(processInstance);

If you need to get a list of users who can do something with a parent process from a subprocess, you can use the following code (in versions >= 1.5.5):

using OptimaJet.Workflow.Core.Subprocess;

var filter = new TreeSearchFilter(processInstance) {
StartFrom = TreeSearchStart.FromRoot,
Include = TreeSearchInclude.OnlyStartPoint
var usersIds = runtime.GetAllActorsForCommandTransitions(filter);