Article

Run Business process from server side

In order to run process GlbProcess1 from server side use code below:

IProcessExecutor processExecutor = UserConnection.ProcessEngine.ProcessExecutor;
var nameValues = new Dictionary<string, string>();
// Add your parameters
nameValues["RecordId"] = entityId.ToString();
processExecutor.Execute("GlbProcess1", nameValues);

If you want to run GlbProcess1 for all records in Case:

var esq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "Case");
esq.PrimaryQueryColumn.IsAlwaysSelect = true;
var entities = esq.GetEntityCollection(UserConnection);
foreach(var entity in entities) {
    var entityId = entity.PrimaryColumnValue;
    IProcessExecutor processExecutor = UserConnection.ProcessEngine.ProcessExecutor;
    var nameValues = new Dictionary<string, string>();
    // Add your parameters
    nameValues["RecordId"] = entityId.ToString();
    processExecutor.Execute("GlbProcess1", nameValues);
}

 

Like 0

Like

Share

3 comments

This code gives an error now. "ProcessExecutor is not usable because of it's protection level" or something like that.

Hi Jonas,

I just checked from my end and I was able to use above article to start a process.



Which version are you using? Could you please provide error screenshot?



Regards,

Dmytro

Hi Dmytro Smishchenko & Tatiana,

Have a follow up question regarding executing a BP from the server side. The article covers how to execute it by passing certain parameters. How does one get back certain out output parameters after the BP executes??



I went through the IProcessExecutor documentation here and it permits to retrieve one result parameter. What if I need to read more than 1 parameter at the end of the business process execution?? Is there any other way to execute a BP from server side code and get the output parameter?



Anastasia's comment in this question - https://community.creatio.com/questions/call-business-process recommends the use of FlowEngine to run the business process. I also went through the class documentation of FlowEngine here. Could not find a way to get BP parameters after execution.



Appreciate your assistance. 

Show all comments