back to top

Creating Reusable Client-Side Code With Modules in Creatio (formerly bpm’online)

With any development, even when customizing Creatio, good code organization is crucial to get the job done right. Good code organization will make your customizations more easily maintainable, easier to read, and easier to create in the first place. One of the ways you can organize your code is using modules. One of the biggest benefits of using modules is the ability to reuse your code. A Javascript module is similar to a class – you define it with a specific purpose, encapsulating the functionality needed for that purpose. Then, you can use that module wherever you need that functionality.

Let’s take a look at the basic structure of a module. First, to create the module, you’ll create a module client schema in your package:

Now, you’ll add your code. Here’s a simple, sample module:

define("UsrMyModule", [], function() {
	Ext.define("Terrasoft.configuration.UsrMyModule", {
		extend: "Terrasoft.BaseObject",
		alternateClassName: "Terrasoft.UsrMyModule",
		
		doSomething: function() {
			console.log("something");
		}

	});

	return Ext.create("Terrasoft.UsrMyModule");
});

In the module above, our module name is UsrMyModule. It contains a single function called doSomething. You can add whatever functionality needed to this module. Make note that the module actually creates an instance of itself and returns it (the last line of code), more on this later. Now, when you want to use this module, you can easily add it and invoke it’s functions.

For example, if you want to use this module on an edit page, such as the Contact edit page, you’ll open the edit page and add it as follows – in the example below we’ll use our module in the onEntityInitialized.

define("ContactPageV2", ["UsrMyModule"], function(UsrMyModule) {
	return {
		entitySchemaName: "Contact",
		methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				
				// call function from module
				UsrMyModule.doSomething();
			}
		},
		diff: /**SCHEMA_DIFF*/[
			//...etc
		]/**SCHEMA_DIFF*/
	};
});

Notice in the code above, we’ve added our module to the AMD modules list at the top of the code:

define("ContactPageV2", ["UsrMyModule"], function(UsrMyModule) {

This loads our module for the page as an object named UsrMyModule. The first part, in quotes, basically says “load this thing”, the second part, not in quotes, gives you the “thing” in a parameter. Previously, when we looked at the code for the module, it created  an instance of itself and returned it. This second part is where we get that created instance. Now we can use this object to invoke the methods in it:

UsrMyModule.doSomething();

That is it. You can now wrap up any code you need in the module and reuse it where necessary. In my next article, I will cover another way to reuse code using mixins.

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.

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