Tuesday, September 8, 2015

Function to make the form read only and skip the fields you want

function formdisable() {
    var skipFields = ",new_fieldtoskip1name,new_fieldtoskip2name,";
 
    var allAttributes = Xrm.Page.data.entity.attributes.get();
    for (var i in allAttributes) {
        var myattribute = Xrm.Page.data.entity.attributes.get(allAttributes[i].getName());
        var myname = myattribute.getName();
        if (skipFields.indexOf("," + myname + ",") != -1) {
            continue;
        }

        try {
            Xrm.Page.getControl(myname).setDisabled(true);
        } catch (err) {}
    }
}

3 comments:

  1. Interesting, thanks Arturo. I might make a slight modification where I pass it in as a parameter.

    Dave J

    ReplyDelete
  2. Sure Dave!, feel free to modify it as you need it.

    ReplyDelete
  3. Please contact me at jlmullikin@emesec.net. I have been trying to contact you from upwork and LinkedIn. I have a great contracting opportunity for you with my company

    ReplyDelete