back to top

Creating Custom Requests and Calling as Functions on a Creatio Freedom UI Page

The anatomy of the code that makes up a Creatio Freedom UI page is quite different than the code for classic pages. However, it is still possible to create custom requests that can be used as functions to make the page code more organized and reusable. This article will show how to create custom requests and call them like functions on a Freedom UI page.

Note, another option is to use modules or classes for better code organization

For example, if you have some code that might need to run on a page’s model init and also on a change event, you could create this code as a custom request on the page, as follows:

// handle the request called cfx.doSomething
{
    request: "cfx.doSomething",
    handler: async (request, next) => {
        // do something here
        return next?.handle(request);
    }
}

You can think of the request handler above as a function that we’ll call when needed. To execute the request (and essentially call that function) we would use the following, for example from the init or changes requests:

// execute the request called cfx.doSomething
request.$context.executeRequest({
    type: "cfx.doSomething",
    $context: request.$context
});

We can also pass parameters in the request as well, using the following syntax to just include them in the request:

// execute the request and pass parameters
request.$context.executeRequest({
    type: "cfx.doSomething",
    $context: request.$context,
    someParameter: "Some value here",
    anotherParam: 10
});

Then, to retrieve the parameters, they will be properties of the request that is provided to our custom request handler:

// handle the request and retrieve the parameters
{
    request: "cfx.doSomething",
    handler: async (request, next) => {
        const someParam = request.someParameter;
        const another = request.anotherParam;

        // do something here

        return next?.handle(request);
    }
}

Lastly, you can also return values from the custom request handler as well. For example, let’s say you want a reusable request to retrieve some data from elsewhere. You could define that request and return some value as follows:

// handle the request and return a result
{
    request: "cfx.getSomeValue",
    handler: async (request, next) => {
        // do something to get the value here

        // now return the result
        return "Some return value";
    }
}

Then to execute that request and get the value returned, you’d simply need to capture and await the result of the request:

// execute the request and await the returned result
const result = await request.$context.executeRequest({
    type: "cfx.doSomething",
    $context: request.$context
});

// do something with the returned value
console.log(result);

For more complex page code, a module or class is always a better route, but for simple page code organization, using requests as functions is a great way to keep the page code clean.

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Ryan Farley
Ryan Farleyhttps://customerfx.com/article/author/ryanfarley/
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.

2 COMMENTS

  1. In the `return “Some return value”;` example, do you know of any issues/potential issues with never calling the `next?.handle(request)` callback? Perhaps this is never an issue for custom handlers, as long as you know not to call them with some callback function added? I must admit I’ve never played around with the `next` callback except for the few examples online for OOTB handlers e.g. cancelling saving.

    • I’e never ran into any problems, per se, but omitting the next?.handle(request) would potentially prevent the ability to override the handler from another layer of the page. I suppose you could avoid this by, instead of returning the value, to instead add the value as a property to the request object and then return normally, allowing another possible handler to function as well.

      Ryan

LEAVE A REPLY

Please enter your comment!
Please enter your name here

AI Readiness Checklist for CRM Teams: Is Your CRM System Ready for AI?

Before using AI in Creatio, make sure your CRM data, users, processes, and automation foundation are ready. Use this practical AI readiness checklist for CRM teams.

Build Your Creatio AI Skills with the 2026 AI Summer Program

Join Creatio’s free 2026 AI Summer Program to learn how to identify, build, deploy, and manage AI agents.

Creatio 10x Is Coming: Join the Webinar to Explore the Future of AI-Native CRM

Learn what's new in Creatio 10x and how AI-native CRM, agentic AI, and no-code automation are shaping the future of customer relationship management. Join the upcoming webinar and discover what's next.

Creatio Unlimited Pricing Explained: AI Packages, Costs, Pros & Cons

Learn what Creatio’s new Unlimited pricing model includes, what it doesn’t include, how AI Action packages work, and the pros and cons for businesses evaluating Creatio.

Using the AI Prompt to Create Dynamic Folders in Creatio

Using Creatio's AI prompt to create the filter for a dynamic folder works best if you specifically ask for that, and if you are as clear and direct as possible about the filtering, conditions.

Related Articles

AI Readiness Checklist for CRM Teams: Is Your CRM System Ready for AI?

Before using AI in Creatio, make sure your CRM data, users, processes, and automation foundation are ready. Use this practical AI readiness checklist for CRM teams.

Build Your Creatio AI Skills with the 2026 AI Summer Program

Join Creatio’s free 2026 AI Summer Program to learn how to identify, build, deploy, and manage AI agents.

Creatio 10x Is Coming: Join the Webinar to Explore the Future of AI-Native CRM

Learn what's new in Creatio 10x and how AI-native CRM, agentic AI, and no-code automation are shaping the future of customer relationship management. Join the upcoming webinar and discover what's next.

Creatio Unlimited Pricing Explained: AI Packages, Costs, Pros & Cons

Learn what Creatio’s new Unlimited pricing model includes, what it doesn’t include, how AI Action packages work, and the pros and cons for businesses evaluating Creatio.

Related Videos