HOW TO INVITE/GET ALL USERS WHICH CAN APPROVE A DOCUMENT IN FURTHER

HOW TO INVITE/GET ALL USERS WHICH CAN APPROVE A DOCUMENT IN FURTHER


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.

1-st option:

To notify users wich 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. Because when you will execute a transition from A to B, the implementation of Activity B will be exectued.

2-nd option:

You can put a code to determine and notify further users in ProcessStatusChanged or ProcessActivityChanged (in versions >= 1.5.5) event handlers.

You can take a next user's ids 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 which can do something with a parent process, but you need to get them from a subprocess, you can use 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);