none
Disable some control on list form based on user group RRS feed

  • Question

  • Hi Guys,

    I have a requirement that need to disable some controls based on user group, can we do this with InfoPath or some other things ?

    Please share any idea.

    Thanks for any help.

    Tuesday, July 9, 2019 2:23 AM

Answers

  • Hi,

    You can use "Content Editor/Script Editor" Web Part to add custom javascript ode on your list forms.

    You can check the current user's group and show/hide fields accordingly.

    For Example: I want to hide "Email Address" field if user is not present in "Email Address Group".

    <script type="text/javascript" src="https://siteUrl/SiteAssets/jquery-3.1.1.min.js"></script>
    <script type="text/javascript">
       $(document).ready(function() {
          $().SPServices({
              operation: "GetGroupCollectionFromUser",
              userLoginName: $().SPServices.SPGetCurrentUser(),
              async: false,
              completefunc: function (xData, Status) {
                  var xml = xData.responseXML.xml;
                  if(xml.search('Email Address Group') != -1) {
                      var feedbackField = $("input[title=Email Address]");
                      feedbackField.parent().parent().parent().hide();       
                  }
              }
          );
       });
    </script>

    References:

    1. How to hide a column for some users or groups
    2. Disable the fields based on the groups

    Please Vote and Mark as Answer if it helps you.

    • Marked as answer by zhw12 Wednesday, July 10, 2019 12:35 AM
    Tuesday, July 9, 2019 5:26 AM
  • Hi,

    Besides SPService code, you can also use InfoPath to achieve this requirement:

    infopath form hide/disable fields based on sharepoint group membership

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by zhw12 Wednesday, July 10, 2019 12:35 AM
    Tuesday, July 9, 2019 9:44 AM
  • Hi

    Do you mean to control the field's permission for different groups? Please refer below link.

    https://sharepoint.stackexchange.com/questions/104197/disable-the-fields-based-on-the-groups


    Justin Liu Office Apps & Services MVP, MCSE
    Senior Software Engineer
    Please Vote and Mark as Answer if it helps you.

    • Marked as answer by zhw12 Wednesday, July 10, 2019 12:35 AM
    Tuesday, July 9, 2019 2:59 AM

All replies

  • Hi

    Do you mean to control the field's permission for different groups? Please refer below link.

    https://sharepoint.stackexchange.com/questions/104197/disable-the-fields-based-on-the-groups


    Justin Liu Office Apps & Services MVP, MCSE
    Senior Software Engineer
    Please Vote and Mark as Answer if it helps you.

    • Marked as answer by zhw12 Wednesday, July 10, 2019 12:35 AM
    Tuesday, July 9, 2019 2:59 AM
  • Hi,

    You can use "Content Editor/Script Editor" Web Part to add custom javascript ode on your list forms.

    You can check the current user's group and show/hide fields accordingly.

    For Example: I want to hide "Email Address" field if user is not present in "Email Address Group".

    <script type="text/javascript" src="https://siteUrl/SiteAssets/jquery-3.1.1.min.js"></script>
    <script type="text/javascript">
       $(document).ready(function() {
          $().SPServices({
              operation: "GetGroupCollectionFromUser",
              userLoginName: $().SPServices.SPGetCurrentUser(),
              async: false,
              completefunc: function (xData, Status) {
                  var xml = xData.responseXML.xml;
                  if(xml.search('Email Address Group') != -1) {
                      var feedbackField = $("input[title=Email Address]");
                      feedbackField.parent().parent().parent().hide();       
                  }
              }
          );
       });
    </script>

    References:

    1. How to hide a column for some users or groups
    2. Disable the fields based on the groups

    Please Vote and Mark as Answer if it helps you.

    • Marked as answer by zhw12 Wednesday, July 10, 2019 12:35 AM
    Tuesday, July 9, 2019 5:26 AM
  • Hi,

    Besides SPService code, you can also use InfoPath to achieve this requirement:

    infopath form hide/disable fields based on sharepoint group membership

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by zhw12 Wednesday, July 10, 2019 12:35 AM
    Tuesday, July 9, 2019 9:44 AM