Edit only some fields when opening the default form

Hi. I would like users to click on an entry in a SharePoint list and have the default form open with only some form fields in edit mode, the rest of the form fields should be in read only mode. What I want to achieve is that the default form doesn't allow users to edit the existing data fields but they can add to a comments field as per this article - Add discussion to a SharePoint form — Plumsail SharePoint Forms Documentation

I have used this method (Edit form as default for a specific SharePoint group — Plumsail SharePoint Forms Documentation) so that the default 'Display' form is in edit mode, however all of the fields are then editable and cannot be changed to read only via the GUI. I'm guessing this may be achievable via code? Or even if this is the best way to accomplish what I'm after?

Thanks in advance!

Dear @aocallaghan,
Some options here:

  1. Use Edit form and set most fields to Readonly mode in editor, users will only be able to edit fields that are not in Readonly mode.
  2. If you use Display form, which you manually switch to Edit mode, you can only add fields that you want to be editable, the rest of the fields data can be presented with Text controls - Text control — Plumsail SharePoint Forms Documentation

Hi

I've tried setting fields to 'readonly' in the Edit form and that works fine... when the user clicks Edit. However I would like the default form that opens when a user clicks on an existing list item to only allow the user to add comments and not edit anything else. The default form that opens is the Display form but that doesn't appear to allow the user to add comments, hence they either need to manually click the Edit button or I change the Display form to allow editing but that then allows them to edit all the fields.

To make sure I understand, is your 2nd suggestion to -

  1. Update the Display form so that it 'embeds' the fields from the list item as text objects so that they are not editable.
  2. Add the fd.spForm._formType = "Edit"; JS code to the Display form so that any non-text objects are editable.
  3. Add the 'Comments' (RTF) field as per Add discussion to a SharePoint form — Plumsail SharePoint Forms Documentation

If I'm correct then that would allow the default form to open (ie Display form) and not allow the user to edit anything except for adding 'Comments' ?

Cheers

Dear @aocallaghan,
Yes, that's an option. This is because on Display form all fields are read-only by default, and switching form type to Edit mode will switch all fields to editable mode, and they are not easily switched to readonly mode with JavaScript.

So if you embed field values in Text controls instead, they won't be editable. Another option is to disable every field you don't want with JavaScript, though it's not quite the same as readonly mode - fields will still appear as fields, not as text, but they won't be interactive.

Third option might be to utilize the comments option from SharePoint instead:

There might be even more options depending on the exact functionality you want to achieve, but I would recommend either using out-of-box SharePoint comments, or if necessary to edit some fields on display form - embed other field values in Text controls instead of using the actual fields.

Thank you. I went with the text controls option and it's working as I need it :smile:

1 Like