3

I want to filter my Workflow 2013 Tasks list only to display the tasks assigned to the current user. Hence I went ahead and set a filter 'Assigned To' is equal to [Me] in the view.

However, I am not seeing the tasks that has a SP Group assigned and the SP group contains the current user.

What am I missing?

3 Answers 3

7

If you have a SharePoint task list where the task is assigned to a SharePoint group, you may notice that the My Task list does not show tasks even if you are a member of the group of which the task is assigned.

Fortunately, there is a simple fix. It does require SharePoint Designer though. Open SharePoint Designer and then open the My Tasks view of the task list in code view. Find the tag and within it add the following:

<Or>
  <Membership Type="CurrentUserGroups">
    <FieldRef Name="AssignedTo"/>
  </Membership>
  <Eq>
    <FieldRef Name="AssignedTo"/>
    <Value Type="Integer">
      <UserID/>
    </Value>
  </Eq>
</Or>

Save the view then open it again in the browser. It should now show any tasks assigned directly to you as well as any tasks assigned to groups of which you are a member.

6
  • Jazakallahu Khairan Bro.. I will check on this inshaALLAH :)
    – Muhammedh
    May 12, 2015 at 14:45
  • Jazakallahu Khairan Bro. Inshallah it will work.
    – Waqas Sarwar MVP
    May 12, 2015 at 14:47
  • InshaALLAH :).. Btw the link to your blog in your profile is not working. Just thought of letting you know.
    – Muhammedh
    May 12, 2015 at 14:48
  • thank you for reminding me, i just change the hosting. my new blog is krossfarm.com
    – Waqas Sarwar MVP
    May 12, 2015 at 14:50
  • Welcome :).. The blog looks good btw (Y)!
    – Muhammedh
    May 12, 2015 at 14:54
0

As per my knowledge out of the box doesn't not has this ability.

You need to programmatically query this. Since its 2013 I believe you can do this using JSLinks. Inside this you should have the validation like Assigned To for current item (that is being rendered) is current user. And if it is a group, you can use JavaScript Object Model to check if current user is part of that group.

3
  • Salams Amal, Thanks for the reply. What do you think of @Waqas's solution?
    – Muhammedh
    May 12, 2015 at 14:46
  • 1
    WSalaam..I think it will work. I never know in 2013 CAML query has <MemberShip> attributes.. Nice to learn new things. May 12, 2015 at 14:47
  • Yep :) Good stuff!!
    – Muhammedh
    May 12, 2015 at 14:49
0

As in my organization, SPD is not allowed to use and PowerShell as well, I have used console application and CSOM to achieve the same. Below is the code if anyone has same situation:

using System;
using Microsoft.SharePoint.Client;

namespace MyConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                ClientContext clientContext = new ClientContext("Your 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 = "@<Where>" +
                       "<Or>" +
                           "<Eq>" +
                               "<FieldRef Name='AssignedTo' />" +
                                   "<Value Type='Integer'>" +
                                       "<UserID />" +
                                   "</Value>" +
                           "</Eq>" +
                           "<Membership Type='CurrentUserGroups'>" +
                              " <FieldRef Name='AssignedTo' />" +
                          " </Membership>" +
                      "</Or>" +
                 " </Where> ";




                // 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;
                viewColl.Add(creationInfo);
                clientContext.ExecuteQuery();
                Console.WriteLine("View created success! Press any key to close!");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
                Console.ReadLine();
            }
    
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.