Lock CRM 2013 Form using script along with locked panel in footer

We had a requirement to lock CRM 2013 form on some condition and it should appear locked.We implemented following code to achieve

the same.(Mix of supported and unsupported scripting)

Below are functions to lock field:

function disableFields(flag) {

    Xrm.Page.ui.controls.forEach(function (control, index) {
        if (doesControlHaveAttribute(control)) {

function doesControlHaveAttribute(control) {
    var controlType = control.getControlType();
    return controlType != “iframe” && controlType != “webresource” && controlType != “subgrid”;

Function needs to be called as below to disable form:

//Code to disable fields

function () {
    var sval = $(this).text();
    if (sval == ‘Open’) {

This will disable CRM 2013 form like mentioned below:


Notice in the above image that there is a lock panel visible below the form.

Following code to enable form fields back:

//Code to enable fields

function () {
    var sval = $(this).text();
    if (sval == ‘Locked’) {

Hope it helps!


One thought on “Lock CRM 2013 Form using script along with locked panel in footer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s