Me Filter Issue - sharepoint

I have added the following field to a custom list definition based on custom content type.
<Field Type="User" DisplayName="Line Manager" List="UserInfo" Required="FALSE" EnforceUniqueValues="FALSE" ShowField="ImnName" UserSelectionMode="PeopleOnly" UserSelectionScope="0" ID="{098E0A5A-8187-481E-B155-B674A406EEAF}" SourceID="{53ca79b7-9ffa-457d-aff8-c71508b09cb1}" StaticName="Line_x0020_Manager" Name="Line_x0020_Manager" RowOrdinal="32" Filterable="TRUE" FromBaseType="TRUE"/>
I am putting [Me] filter on this column in a view. The filter is not able to filter the records for the logged in user.
Am I missing something?
EDIT
Interestingly if I add similar column through SharePoint UI the filter works fine. Any clues, ideas welcome.

Is the [Me] filter work on native list definition?
Or, are you sure that your SharePoint installation using English version?
Maybe you should change field type from "User" to "people or group"

Phew!! This got resolved and was one of the most frustrating things. I am not sure if this was an issue with the way I defined the schema below or whether it’s a bug with SharePoint.
I ran a profiler to see what’s going on under the hoods and found a query (pretty huge for me to digest ) where in the RowOrdinal was being used extensively with a predefined value as 0 or 1. As I was using “32” as RowOrdinal, it looked shady to me. I changed it to “0” and bingo!! The filter started working.
BTW here is what MSDN says about it – "Optional Integer. Specifies the database location for the field."
Doesn’t appear like it should take part in records filtering.
So, to close the field should be defined as
<Field Type="User" DisplayName="Line Manager" List="UserInfo" Required="FALSE" EnforceUniqueValues="FALSE" ShowField="ImnName" UserSelectionMode="PeopleOnly" UserSelectionScope="0" ID="{098E0A5A-8187-481E-B155-B674A406EEAF}" SourceID="{53ca79b7-9ffa-457d-aff8-c71508b09cb1}" StaticName="Line_x0020_Manager" Name="Line_x0020_Manager" RowOrdinal="0" Filterable="TRUE" FromBaseType="TRUE"/>

Related

BDC model/search connector and multi value field with refinment

BDC model:
My BDC model's entity has a property named Color.
The TypeName is specified as System.String[].
<TypeDescriptor Name="Color" TypeName="System.String[]">
<Properties>
<Property Name="RequiredInForms" Type="System.Boolean">false</Property>
</Properties>
</TypeDescriptor>
Database:
In my database (my BDC content source) I added column values like this one:
;#Blue;#Green;#Yellow;#
Search Schema
I created a new managed property and enabled multiple values (and also refinable - active, queryable, retrievable, safe).
Search Results
Filtering on a specific color via search works.
Example: RsExpAdvWorksProductColor:"blue"
Search Refinement
However I cannot refine on colors.
Adding a refiner on my Managed Property shows up like that:
Color
;#Blue;#Green;#Yellow;#
;#Green;#Yellow;#
;#Red;#Green;#Yellow;#Blue;#Black;#Cyan;#
Obviously the single values are not treated as such - the whole "string" of "special-delimiter" separated values is being shown as a refinment criteria.
Any hints?
Update 2015-03-20: I took a closer look at the built-in multi choice columns. In search results they are being returned as "Value1;#Value2;#" and so on. Basically there is a trailing Red;#Blue;# separator - no leading ;#Red;#Blue;# one. Much to my regret that didn't solve my problem.
Update 2015-03-20: Surprise surprise. It is in fact "working as designed" (like so many things in SharePoint :P). What I am looking for has to be dealt with separately. It behaves exactly the same with built-in multi choice fields so there is nothing wrong with my BDC/Search integration.
Regarding the refiner, have a look at the following links...
http://www.eliostruyf.com/part-6-create-multi-value-search-refiner-control/
https://hyankov.wordpress.com/2014/12/15/sharepoint-2013-refiner-multi-value-contains-instead-of-an-equals/

How do I get the guids of taxonomy/metadata terms for updating lists?

I'm integrating a legacy system with SP2010 using a literal SOAP calls. I can do a call such as CopyIntoItems or UpdateListItems and doing so, set metadata fields by providing a Fields node such as:
<Fields>
<FieldInformation Type="Note" DisplayName="Country_0"
Id="de1e6424-7a8a-42a5-8d21-73402fe2e609"
Value="UK|91c89925-16e6-4d41-9e71-ec45e8f2a113" />
...
</Fields>
In the Value attribute, I have to give the guid of the taxonomy or metadata term. That works fine in the above example since I happen to know the guid of the term UK. However, how can I dynamically figure out what the guid of some other value, say France for example, would be? I was thinking of making a utility to get them all and cache them on my system somehow so I can look them up easily, but where are they defined?
Possibly a stupid question, I get the feeling I've missed something...
The GetList call should allow you to get all the ID's.
But the UpdateListItems (and) call should work using just the internal names.
From the MSDN Sharepoint 2010 forum:
http://social.msdn.microsoft.com/Forums/eu/sharepoint2010general/thread/63553372-b87f-4d69-8d4c-63fb8a7b3c6d
Not sure if this is the best way but it's the answer I'm going with for the time being.

Content Query Web Part - How do you OrderBy when you QueryOverride?

How do you order items when you override the QueryOverride property of the Content Query Web Part?
I have been given responsibility for a Web Part which extends the Content Query Web Part. The QueryOverride property of this Web Part is programmatically changed. Currently, the Web Part does not function as designed, as it does not order the items according to the appropriate field.
If I add an <OrderBy> node to the QueryOverride property I get an error message along the lines of 'something wrong with the query this web part is...' and the Content Query Web Part doesn't seem to have an OrderBy property which I could use instead.
The "QueryOverride property" part of this msdn article seems to suggest I should be able to add an <OrderBy> node to the QueryOverride but a number of web sites I've been reading suggest that this is not true.
So, how do you order items when you override the QueryOverride property of the Content Query Web Part?
Does your QueryOverride statement contain any Whitespace/linebreaks by any chance? I think I recall a while back having a situation where the QueryOverride needed to be all contained on one line, with no spaces between xml tags.
Weird I know, but try it out.
Also, for reference see the first community comment on the MSDN page http://msdn.microsoft.com/en-us/library/aa981241.aspx
THanks for this. Just to clarify, there should be no white spaces before or after the tags as well.
This did not work:
<![CDATA[
<OrderBy><FieldRef Name="EndDate" Ascending="False"/></OrderBy>
<Where>
But this did:
<![CDATA[<OrderBy><FieldRef Name="EndDate" Ascending="False"/></OrderBy><Where>
Wierd but thanks again for posting this answer, it saved me a lot of time.

SPSiteDataQuery fails if field of type UserMulti is specified in ViewFields

I`m trying to query all task lists. I have modified default Task content type to allow multiple choices for Assigned To field (Internal name - AssignedTo).
My SPSiteDataQuery fails if I specify <FieldRef Name='AssignedTo' /> (Returns no results)
If I add Nullable='TRUE' then results are returned but AssignedTo field ends up being null for all records. If i'll add Type='UserMulti', that won't help.
Looks like a very nasty bug. Is there a workaround? (Well, besides looping all task lists and querying...)
Thankyou.
We faced the same exact issue two months back, I came across this thread , after which I used the Nullable='TRUE' Type='UserMulti' Still then we were not able get it working. And my manager sat with MS support to just find out that Installing the MOSS 2007 SP2 solved the issue with out a code change. You can try out SP2 in case if you haven't already.

Add a lookup field to a content type in sharepoint

How can I add a lookup field to a content type in sharepoint using the xml definition? (I'm getting errors).
Things to note:
- The lookup list will exist when the content type is added to the document library.
- The lookup list will always have the same name.
- The lookup list has a space in the name.
This is what I've added to the xml:
<Field ID="{GUID}"
Type="Lookup"
List="$Resources:core,lists_Folder;/List%20Name"
ShowField="Title"
Name="MyLookupFieldName"
DisplayName="MyLookupFieldName"
StaticName="MyLookupFieldName"
Hidden="FALSE"
Required="FALSE"
Sealed="TRUE"
>
When I then programatically add the content type to a document library I get an exception (with no useful information), and the following is logged to the sharepoint log:
08/18/2009 17:13:39.50 w3wp.exe (0x08B8) 0x11B0 Windows SharePoint Services Database 6f8g Unexpected Unexpected query execution failure, error code 8114. Additional error information from SQL Server is included below. "Error converting data type nvarchar to uniqueidentifier." Query text (if available): "{?=call proc_GetListMetaDataAndEventReceivers(?,?,?,?,?,?)}"
Luckily, in SharePoint 2010, you can declaratively do this by setting all required properities as shown in the following working example.
<Field Type="Lookup" DisplayName="Link Type" Description="Represents link type."
Required="TRUE" EnforceUniqueValues="FALSE" List="Lists/Links Types" WebId="~sitecollection"
Overwrite="TRUE" PrependId="TRUE" ShowField="Title" UnlimitedLengthInDocumentLibrary="FALSE"
Group="Research Links Columns" ID="{a15e9fa2-4ea0-41f1-a583-b21d53cf72d3}"
SourceID="{30650f6f-fbb8-4acc-a935-29745f5d3c59}" StaticName="Link_x0020_Type"
Name="Link_x0020_Type" Hidden="FALSE" ReadOnly="FALSE"></Field>
It's important to set WebId to have value of "~sitecollection" and set Overwrite to be TRUE.
More info
The problem is that you need to reference the GUID of the list not its title. As you probably won't know the GUID of the list then you can't do this without executing some custom code afterwards.
Even if you aren't using VSeWSS, the last steps in the post dahlbyk has linked to show you how to do this. Chris O'Brien has gone to the trouble of making a CodePlex project that will help you if you aren't using VSeWSS.
Ok, so I couldn't get the xml definition of a field for a content type to work for me for some reason. I did find out how to do it in code. The solution that worked for me is to not add the Field definition in xml, instead add it in code:
Add the content type to the list (in site definition code, or wherever).
Add a field lookup to the given SPWeb (so the field is a web? field, rather than a site field)
Add a new field link to the list content type.
Update the content type.
For example:
SPContentType myContentType = myWeb.Site.RootWeb.ContentTypes["MyContentType "];
myLib.ContentTypes.Add(myContentType);
myContentType = myLib.ContentTypes["MyContentType "];
myWeb.Fields.AddLookup("MyLookupFieldName", myWeb.Lists["MyLookupListName"].ID, false);
SPFieldLink myFIeldLink = new SPFieldLink(myWeb.Fields["MyLookupFieldName"]);
myContentType.FieldLinks.Add(myFIeldLink);
myContentType.Update();

Resources