back to top

Programatically Disabling Controls on a Creatio Freedom UI Page

There are likely times that business rules might not work as you need for some scenarios for disabling controls. For example, some scenarios might include reading data from other records using a model query. Luckily, you can do this programmatically pretty easily using the steps below:

  1. Add an attribute
  2. Bind the attribute to the control’s readonly property
  3. Add code to set the attribute to true/false to make the control enabled or not

For a sample for this article, we’ll simply disable the Account Type if it’s value is “Customer”. Note, this particular scenario we could do with business rules, but keeping things simple just do demonstrate the points needed.

Add an attribute to the viewModelConfigDiff, the one below is named “IsTypeEnabled”:

viewModelConfigDiff: /**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/[
    {
        "operation": "merge",
        "path": [
            "attributes"
        ],
        "values": {
            "IsTypeEnabled": {
            	value: true
            }
        }
    }
]/**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/

Now, I wire up my attribute to the Type control in the viewConfigDiff:

{
	"operation": "merge",
	"name": "Type",
	"values": {
		"readonly": "$IsTypeEnabled | crt.InvertBooleanValue"
	}
}

Note, I am using a converter to invert the value since my attribute indicates it’s enabled, but the property expects the inverse. If I wanted, I could make my attribute the same as what the property expects and call it “IsTypeDisabled”. Then, I wouldn’t need the converter and could just bind it as below, without the converter:

{
	"operation": "merge",
	"name": "Type",
	"values": {
		"readonly": "$IsTypeDisabled"
	}
}

Lastly, I’ll add a change request handler to listen for values in the Type attribute (which also triggers when the page is initially populated, which is when request.silent==true):

handlers: /**SCHEMA_HANDLERS*/[
	{
		request: "crt.HandleViewModelAttributeChangeRequest",
		handler: async (request, next) => {
 
			if (request.attributeName === "Type") {
				request.$context.IsTypeEnabled = (!request.value || request.value.displayValue !== "Customer");
			}
 
			return next?.handle(request);
		}
	}
]/**SCHEMA_HANDLERS*/

With all this in place, if I open an Account with Type=Customer, or change the Type to Customer it is disabled/readonly.

One thing to note, many controls have both a readonly and a disabled property, not sure what the difference is, both seem to work for me, but the readonly seems to be the one that gives the control the visual lock icon. The disabled property also disables the control, but you don’t get the lock icon for the control.

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