-3

I am using CRM 2016 and I have a custom entity. After submitting a new record I need to make most fields read only.

How can I disable editing on most field records after submitting the form?

Henk van Boeijen
  • 7,357
  • 6
  • 32
  • 42
user3415175
  • 101
  • 9

1 Answers1

1

If the form contains only a few fields, you could create a business rule to disable the fields.

Or, if you have a lot of fields you might want to use JavaScript:

function onLoad(list) {
    if (Xrm.Page.ui.getFormType() == 2) {
        var list = ['field1', 'field2', 'field3', 'field4'];
        disableFields(list);
    }
}

function disableFields(list) {
    for (var i = 0; i < list.length; i++) {
        Xrm.Page.getControl(list[i]).setDisabled(true);
    }
}

And, Field Level Security is another option to explore.

If you wanted to disable all the fields, you could configure the security role(s) so that when you assign the record to another user or team, it becomes read only for the users you want.

Also, for the record, this JavaScript command would disable all fields:

Xrm.Page.ui.controls.forEach(function (a) { a.setDisabled(true) }); 
Aron
  • 3,877
  • 3
  • 14
  • 21