Question

Call Business Process from a Script Task

Hi everyone,

 

For some reason, I need to call a Business Process from a Script Task with some parameters.

I can call my process from my section, with this code:

callCustomProcess: function () {
    // Getting identifier of account main contact.
    var contactParameter = this.get("PrimaryContact").value;
    // The object that will be transferred to execureProcess method as an argument.
    var args = {
        // Name of the process that should be run.
        sysProcessName: "CustomProcess",
        // Object with the value of ContractParameter input parameter for CustomProcess parameter.
        parameters: {
            ContactParameter: contactParameter
        }
    };
    // Running of user business process.
    ProcessModuleUtilities.executeProcess(args);
}

It works great, but I need to do something similar from another Business Process, in C#, with the Script Task object ..

 

Thanks !

Like 0

Like

3 comments

Technically you can call a business process from a business process. But if you need that, then you've probably made an architecture mistake. If you need to call a sub process after some c# code, just create two separate script tasks and a "Sub process" element between them. This will give you the same functionality as calling a process from a script task but it will be much more correct. 

Eugene Podkovka,

Thanks for your answer, but I don't really understand.

Here's the problem: I have a Business Process, called "A", which has no parameter, and a Business Process, called "B", which takes an Id as parameter.

"A" does some analysis on my datas, and then I need to call "B" on some records, then I did somthing like:

var esq = new EntitySchemaQuery(...);
...
var entities = esq.GetEntityCollection();
 
for (var entity in entities) {
    var id = entity.GetTypedColumnValue<Guid>("Id");
    //I need there to call "B" with id as parameter
}

I don't think there is a solution to my problem without using Script Task, that is why I tried to call a sub process from my Script Task.

It's a very bad idea to run a separate business process for each record in a selection. The system will freeze and the processes will block each other. Please process the result list of entities via C# code instead of the business process or find another architecture solution.

Show all comments