Thursday, February 17, 2011

How to make My group task webpart from My task

Hi,

We all are using my task web part (superb out of the box web part)

but most of the time we are having requirement where a task is assign to a group then that task should also see in my task.

Because normally we are assigning a task to a group and any person from that group can take care of that task.

So here is a trick how to make my group task web part from my task web part

Thanks to Walid.Hammouda to for his answer on MSDN fourm


Here is the trick how we had achieve this.
1. Add content query web part on the page.
2. Edit that web part. In Query section select Source as task list (you can browse and select task list)
3. Set Additional Filter with “Assigned To” --> “is equal to” --> [Me]
4. Apply it

Now if you see that web part must looks like normal task web part.

Now export that web part.

Save it on your pc.

It should have .webpart extension.

Open it with notepad(or any editor)

Find “QueryOverride” property. (it must be blank) like this
<property name="QueryOverride" type="string" />

now add below query inside
<property name="QueryOverride" type="string" ></property>

here is the query

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


Note: keep in mind that query shown above should be html encoded inside the property.

That’s it.

Now save it and upload it and add to your page.

Now check it should retrieve task assigned to your group also.

We cannot use same web part to other site because when we are exporting this web part it has reference of List guid and view guid so to deploy it you have to do this exercise again.

12 comments:

Anonymous said...

That is really awesome man..you guys rock

Anonymous said...

Hey, that is what i was lookin for..Thanks

Adrien said...

hello,

I did all this and when I import the webpart, I get the following error:
There is a problem with the query that this Web Part is issuing. Check the configuration of this Web Part and try again

Here is what I did:

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

SharePoint Kings said...

Adrien,

ya we also got couple of comments on the similar issue that you are getting.

but we in our condition its working the way its mentioned.

still we suggest check your query is HTML encoded. so "<" will "& lt;" without space and similar for > also

if still its not working you can try to put your query in CDATA like this way

<property name="QueryOverride" type="string"><![CDATA[<Or>
<Eq>
<FieldRef Name="AssignedTo"/><Value Type="Integer"><UserID/></Value>
</Eq>
<Membership Type="CurrentUserGroups"><FieldRef Name="AssignedTo"/></Membership>
</Or>]]></property>

and in this case inside CDATA do not encode HTML keep it as it is

Paul said...

Is is possible to modify the query to search by the values in a column in another list?

SharePoint Kings said...

Paul,
not sure for any other site but this web part has a lot of property when you open it exported file tonotepad (or any editor).

there might be possible that we have to set some property so that it can get task from other site as well.

but we do not have exact idea for now.

if we get it we will surly share that.

Anonymous said...

Hello,

Thanks a lot for your post. I am trying to use this tip by ading the follwing part:










But I am having the following error: file format is not valid.

I am using Moss 2007.

Any help would be appreciated

Many thanks
T.

SharePoint Kings said...

you might be breaking while converting CAML to html encoded.
else file format error will not be there.

Jess said...

This is awesome and just what I'm looking for if it would work properly (or at least what I think it should do). I'm returning tasks assigned to me, but not group tasks that I'm a member of. Group tasks aren't showing at all. Any ideas? TY!

SharePoint Kings said...

Jess,
are you trying with admin or system account?

Anonymous said...

I spent like 5 hours trying to make it work and THE ONLY WAY it worked was when I added the where clause:

]]>

Thank you anyway.

SharePoint Kings said...

Anonymous,
thanks a lot for sharing this helps a lot to others.




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com