Easy way to make all fields readonly?

Forums Dynamic Forms for SharePoint Easy way to make all fields readonly?

Viewing 5 reply threads
  • Author
    • #20774
      Keith Hudson

      We are trying to rebuild some lists/forms that were created in another system (not SharePoint). In some cases, the forms have dozens and in a few cases even more than 50 sections, with complex rules for which fields are editable and which are readonly. We would like to be able to create a rule or function that turns all fields on the form readonly unless except for the fields on the tab that matches the current section being worked on. We anticipate using a separate tab for each section of the form, although that may be difficult for forms with over 50 sections.

      A. Is there code we can use to make all fields read only? If so, we could create a rule for each tab on the form that makes all fields read only except for the tab currently being worked.

      B. Any other ideas of how to simplify the creation of these very complex forms?

    • #20799
      Alexander Bautz

      You can loop over all visible fields and set them readonly with this custom js snippet:

      var arrToSetReadonly = [];

      Then you can make the fields in the current tab editable like this:

      var arrToSetEditable = [];

      See what you can do with this example code.

      Regarding QB:
      How many fields do you have in one of these forms? – If you have a large number of fields, your form might be a bit slow to handle – especially if you use an older version of IE. You might want to look into splitting the form into one “mother” and several “children” for example using vLookup.

      Best regards,

    • #27829
      Anne Maki

      Hi Alex,
      I had a similar question as Keith and tried to apply the solution you presented above. I put the “set to read only” steps within a function in the Custom JS and I call that function within a rule that runs when the form is loaded (edit mode). However, when testing, I get two error messages (see attachments) and the form fields still end up as editable.

      Any idea what could be happening?


    • #27833
      Alexander Bautz

      From the error message it looks like there may be a bug in your code. Try bringing up the developer console (hit F12 > Console) and try pasting and running the function there to see if it works. You will bet better error messages when you do it like that.


    • #28810

      Is there are easy way to set all invisible fields (fields that I have set to hide using “.hide” in my JS ) in a tab to clear out or empty them when form is saved?

      i have tried this
      $(“td[style$=’display: none;’]”).closest(‘tr’).find(“select”).each(function(i) {

      But it is picking all the selects boxes not just one where display: none.

    • #28830
      Alexander Bautz

      Not sure how your code looks, but if you have an array of the internal names of the fields you hide you can do it like this:

      var arrOfHidden = ["FieldOne", "FieldTwo"];
      jQuery.each(arrOfHidden, function(i, fin){
          setFieldValue(fin, "");


Viewing 5 reply threads
  • You must be logged in to reply to this topic.