How to enable/disable task list columns based on the current user - SharePoint 2016

Marwa Mostafa 1 Reputation point
2021-01-13T07:52:27.88+00:00

Hello,

Our case is that we have a task list that I want to disable some fields like due date for some users and just keep it enabled for the admin user.

I previously used SharePoint Designer to create a custom edit page and set the required fields to read-only but this was using "Design" mode in SharePoint 2010 and the new form is available for all users even the admin so the fields are disabled for every one.

Recently, we have upgraded to 2016. I don't know if there is a way to make the custom edit form be available for end users while the std one for the admin or I could set the std edit form as the default again but control whether the fields are enabled or disabled based on the user.

So could you please advise how to do so. I know javascript could help in achieving this but I don't know how to apply this so could anyone please help in this.

Thank you in advance
Regards,
Marwa Mostafa

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,280 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,773 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,593 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Echo Du_MSFT 17,136 Reputation points
    2021-01-14T08:48:34.523+00:00

    Hello @Marwa Mostafa ,

    Please follow steps to Hide SharePoint List Columns based on User Permissions:

    • Place the below script in a text file, upload to the Site Assets library to store files

    The Hide Field Script.txt

    • Go to the Task List, click Default New Form under the List Tab. 56513-1.png
    • On the NewForm.aspx, click Add a Web Part to add Content Editor web part 56514-2.png
    • Edit Web Part and entry the link of a text file

    56515-3.png

    • Apply and Stop Editing

    Thanks,
    Echo Du

    ==========

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.