SharePoint Online: Show All Tasks Assigned to My Group

Requirement: In SharePoint Online Task List, Get All Tasks Assigned to the Logged-in User and User’s Groups.

If you want to filter task list items assigned to the current user, you can simply set the [Me] filter in view settings. But If a task item is assigned to a group and the logged-in user is a member of that group, how do we show them? Well, there is no way to set such a filter from the web user interface. So, let’s create a new list view using PowerShell to filter task list items assigned to the current user and current user’s groups in SharePoint Online.

sharepoint online show tasks assigned to my group

Get All Tasks Assigned to the Current User and Current User’s Groups

Although you can edit the query with SharePoint designer, let’s create a new list view using PowerShell, which filters all tasks assigned to the current user and the current user’s groups.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Set parameter values
$ListName ="Project Tasks"
$ViewName="My Group Tasks"

Try {
    #Setup Credentials to connect
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials
    #Get the List
    $List = $Ctx.Web.Lists.GetByTitle($ListName)
    #Check if the View exists in list already
    $NewView = $ViewColl | where { ($_.Title -eq $ViewName) }
    if($NewView -ne $NULL)  
        Write-host "View '$ViewName' already exists in the List!" -f Yellow
        #Define the CAML Query - Filter Assigned to: Current User or Current User's Group
        $ViewQuery = "@
                                <FieldRef Name='AssignedTo' />
                                    <Value Type='Integer'>
                                        <UserID />
                            <Membership Type='CurrentUserGroups'>
                                <FieldRef Name='AssignedTo' />
                    </Where> "

        $ViewCreationInfo = New-Object Microsoft.SharePoint.Client.ViewCreationInformation
        $ViewCreationInfo.Title = $ViewName
        $ViewCreationInfo.Query = $ViewQuery
        $ViewCreationInfo.RowLimit = "100"
        $ViewCreationInfo.ViewFields = @("Title", "Status", "DueDate", "AssignedTo") 
        #Add List View
        $NewView =$List.Views.Add($ViewCreationInfo)
        Write-host "New View Created in the List Successfully!" -ForegroundColor Green  
Catch {
    write-host -f Red "Error Adding View to List!" $_.Exception.Message

and the list view shows tasks assigned to my group and me

sharepoint online view task assigned to my group

This view lets you see all the tasks assigned to your group in one place.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

3 thoughts on “SharePoint Online: Show All Tasks Assigned to My Group

  • I used CSOM with console application for the same as powershell and SPD not allowed in my organization.
    Below is the code I did using reference of above powershell. thanks a lot!!

    using System;
    using Microsoft.SharePoint.Client;
    namespace MyConsoleApplication
    class Program
    static void Main(string[] args)
    ClientContext clientContext = new ClientContext(“Site URL”);
    Web web = clientContext.Web;
    List list = web.Lists.GetByTitle(“Workflow Tasks”);
    ViewCollection viewColl = list.Views;

    // Specify the columns that should be displayed

    string[] viewFields = { “Title”, “AssignedTo”, “Status”, “Created” };
    string ViewQuery = “@” +
    “” +
    “” +
    “” +
    “” +
    “” +
    “” +
    “” +
    “” +
    ” ” +
    ” ” +
    “” +
    ” “;

    // Specifies the properties used to create a new list view

    ViewCreationInformation creationInfo = new ViewCreationInformation();
    creationInfo.Query = ViewQuery;
    creationInfo.Title = “AllMyTasks”;
    creationInfo.RowLimit = 100;
    creationInfo.ViewFields = viewFields;
    creationInfo.ViewTypeKind = ViewType.None;
    creationInfo.SetAsDefaultView = false;
    Console.WriteLine(“View created success! Press any key to close!”);
    catch (Exception ex)


  • Can we use CSOM to achieve the same? Powershell or spd is not allowed to use in my org.

  • This is very useful post to me and my team. I was not about this view approach. Saved lot of coding effort and time for me and my team.

    Thanks – Jigar


Leave a Reply

Your email address will not be published. Required fields are marked *