Make form read-only using JavaScript 

Posted On September 23, 2022 by Richie Jacob Posted in  Tagged in ,

One way to lock down a form is through JavaScript.

Let’s go through how to do this by looking at the code.

var formCustomizations = {
    disableForm: function (executionContext) {
        let formContext = executionContext.getFormContext();

let formControls = formContext.ui.controls;

formControls.forEach(element => {
            if (element.getName() != "" && element.getName() != null) {

Here when the JavaScript Function Is called and the execution parameter is passed, the user can see the desired output.


Provides the properties and methods to retrieve information about the user interface (UI) controls for several sub-components of the form.

formControls.forEach(element => {
if (element.getName() != "" && element.getName() != null) {

Here the forEach loop will traverse and see if there are any fields that are not blank and the field value is not null, then set all that fields to read only on that form.

Hope this helps!

Share Story :

Secured By miniOrange