Starting a Process from Client-Side Code on a Creatio Freedom UI Page

In a previous article I outlined how to start or execute a process from client-side code on a classic Creatio page. This article will show you how to start a process from code on a Freedom UI page. Like most things in a Freedom UI page, we’ll start the process by using the HandlerChainService to initiate a crt.RunBusinessProcessRequest request. The HandlerChainService is a part of the Creatio DevKit SDK.

To use the devkit, you’ll need to add “@creatio-devkit/common” to the modules list of your page. This will look like this (note the “@creatio-devkit/common” in the square brackets and the sdk without quotes in the parenthesis):

define("UsrMyCustomEntity_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/, 
function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
	return {
		// ... the rest of the page here
	};
});

Now, with that module available, you can access things in the SDK, such as the HandlerChainService class. We’ll get an instance of the HandlerChainService, then execute the request, passing the process name (code) and can also include any parameters we need to pass into the process. Let’s take a look at the code below:

const handlerChain = sdk.HandlerChainService.instance;
const result = await handlerChain.process({
	type: "crt.RunBusinessProcessRequest",
	processName: "UsrSomeProcess",
	processParameters: {
		AccountId: await request.$context.Id,
		SomeParameter: "Some Value"
	},
	$context: request.$context
});
					
if (result.success) {
	// process was sucessfully executed
}

In the code above, we’re executing the process named “UsrSomeProcess”. This process has two parameters we’re passing into it (1) AccountId, which we’re populating from the Id on the page, and (2) a param named “SomeParameter”. It is executed and the result will tell us if it was started successfully.

Want content like this delivered to your inbox? Sign up for our newsletter!
ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

5 Comments

  1. Hey Ryan.
    Do you know if it is possible to get the resultParameterValues from the result?

    Reply
  2. Hey Ryan. Maybe I’m barking up the wrong tree here completely…
    I am playing with an Angular Component, my plan was to use a Business Process to perform validation (a little more than a regex test), I was initially going to call a web service to do validation, but thought maybe the BP would be an easier way to manage the rules.

    Do you have any ideas how I could achieve this using a Business Process?
    I could call the BP from the web service…

    Reply
    • Hi Gary,

      Yes, the only option is to create a configuration service and then call the service from C# code there. When executing a process via C# code, it *is* possible to get back the process params, so you could then return them from the service to the UI.

      Ryan

Submit a Comment

Your email address will not be published. Required fields are marked *