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.

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.

Submit a Comment

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

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!