I'm trying to gather all the tasks of a certain content type for a certain user. To accomplish this I'm using a SPSiteDataQuery which looks like this:
string where = String.Format(@"<Where>
<And>
<BeginsWith>
<FieldRef Name='ContentTypeId'/>
<Value Type='Text'>0x0108010031C20CDC28544f93B27958D36ACBE2F5</Value>
</BeginsWith>
<Eq>
<FieldRef Name='AssignedTo'/>
<Value Type='Text'>{0}</Value>
</Eq>
</And>
</Where>", userValue.ToString());
query.Query = where;
DataTable results = web.GetSiteData(query);
It works fine if I just want to filter for the content type but filtering for the user fails.
Here is what I think the problem is.. the AssignedTo field contains values that look like this
17;#TestUser01
But my regular LoginName contains the claims string and domain and looks like this
i:0#.w|test\TestUser01
I tried to create the SPFieldUserValue to get the same user-string that is found in the AssignedTo-field.. like that:
SPFieldUserValue userValue = new SPFieldUserValue(web, SPContext.Current.Web.CurrentUser.ID, SPContext.Current.Web.CurrentUser.LoginName);
.. but then I just get a value that looks like this:
17;#i:0#.w|test\TestUser01
..and I still get no results from my query..
How can I get the correct string to execute my query?