List view to show item assigned to SharePoint group

SharePoint out of box list view filter gives us an option to create a view that can show the list of items assigned to logged in user, but there is no filter option available to show items assigned to a group.

We can handle this type of scenario by setting the item level permissions, so that the users will be able to show the items/documents for which they have access, but we will be facing issues when the user needs access to update the item in a later point of time.

I am going to explain you a way how we can create these kinds of view using PnP PowerShell

  1. Create a column 'AssignedToGroup' in the list
  2. Set the value of group for which you want to show the item
  3. Create PowerShell script, connect to SPO site using 'Connect-PnPOnline'
  4. Use the command 'Add-PnPView' to create the view( example :Add-PnPView -List "List Name" -Title "View Name" -Fields "Title","Address" -Query 'Valid CAML Query')

CAML query : 
            <Where>
              <Or>
                <Membership Type=\"CurrentUserGroups\">
                  <FieldRef Name=\"AssignedToGroup\"/>
                </Membership>
                <Eq>
                  <FieldRef Name=\"AssignedToGroup\"></FieldRef>
                  <Value Type=\"Integer\">
                    <UserID/>
                  </Value>
                </Eq>
              </Or>
           </Where>        

With this approach we can create complex view. Further you can format the view using JSON list view formatting and show the content on a modern page by adding list view webpart. This way we can achieve complex views creation ,formation and displaying the records in a modern page without creating SPFx webpart or Power Apps forms.

Reference Links :

要查看或添加评论,请登录

Kintali Prasanti的更多文章

  • PnP Graph

    PnP Graph

    Do you have a requirement to get or update data in M365 apps, like outlook, one drive etc..

  • Viva Connections

    Viva Connections

    Viva connection allows us to bring SharePoint intranet site in MS Teams 1. Create SharePoint intranet site 2.

  • Disable consent form in PowerApps

    Disable consent form in PowerApps

    Execute the below PowerShell command to disable consent popup in PowerApps. Set-AdminPowerAppApisToBypassConsent…

  • Virtual tables

    Virtual tables

    Virtual tables in Dataverse provides you the feasibility of connecting your SharePoint list with Dataverse and use it…

  • Get all PowerApps in your environment

    Get all PowerApps in your environment

    Would you like to get all the PowerApps available in your environment? Use the PnP command "Get-PnPPowerApp" to get all…

  • Power Automate Best Practices

    Power Automate Best Practices

    1. Label/ Name every action 2.

  • Create sites and content from any where using the SharePoint App Bar

    Create sites and content from any where using the SharePoint App Bar

    The App bar present on the left side of SharePoint site gives the option to create the sites and content from anywhere.…

  • Hide upload option from document library

    Hide upload option from document library

    We can hide the upload option from document library using JSON format, below are the steps. #sharepointonline Create a…

  • Get Site Id with Graph API

    Get Site Id with Graph API

    Execute the below query in Graph explorer , replace the tenantname and sitename placeholders. https://graph.

  • Disable comments section in Modern Pages.

    Disable comments section in Modern Pages.

    To hide the comments section for individual pages : Edit the page Scroll to the bottom Select ‘off’ from the toggle…

社区洞察

其他会员也浏览了