User field with multiple users to check via schema.xml
- when you create lists in sharepoint, it's possible to add afield for choosing a person or multiple persons.
I want exactly that for my list template. I have the following CAML syntax:
<Field Id="{8ADC8169-6BA9-4d7e-B77D-B0F8B79BBEC5}"
Name="Vertreter"
BaseType="Text"
DisplayName="Vertreter"
Type="User" Sealed="TRUE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInNewForm="TRUE"
ShowInListSettings="TRUE"
DisplayNameSrcField="Account"
List="UserInfo"
SourceID="http://schemas.microsoft.com/sharepoint/v3"/>
This works fine, you can select a user there. But I didn't find two options:- To be able, to select multiple people for this column
- To restrict this field to people only, not user groups
Thanks
答案
- Who should get the idea, that you just have to put "Multi" behind the type text, to have multiple values in a field, so that it looks like this:
<Field Id="{8ADC8169-6BA9-4d7e-B77D-B0F8B79BBEC5}"
Name="Vertreter"
BaseType="Text"
DisplayName="Vertreter"
Type="UserMulti" Sealed="TRUE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInNewForm="TRUE"
ShowInListSettings="TRUE"
DisplayNameSrcField="Account"
List="UserInfo"
UserSelectionMode="PeopleOnly"
SourceID="http://schemas.microsoft.com/sharepoint/v3"/>
The other option "UserSelectionMode" is also not documented. Now it is in a forum's post ;)
By the way, I found the XML-structure of list definitions. So if you want to know, how a list definition done via SharePoint UI is done in CAML, take a look into the content-database of the web application, table dbo.AllLists, pick the list, where you want to get the definition and copy the content of the field tp_Fields into an XML-editor .... there it is.
全部回复
- Who should get the idea, that you just have to put "Multi" behind the type text, to have multiple values in a field, so that it looks like this:
<Field Id="{8ADC8169-6BA9-4d7e-B77D-B0F8B79BBEC5}"
Name="Vertreter"
BaseType="Text"
DisplayName="Vertreter"
Type="UserMulti" Sealed="TRUE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInNewForm="TRUE"
ShowInListSettings="TRUE"
DisplayNameSrcField="Account"
List="UserInfo"
UserSelectionMode="PeopleOnly"
SourceID="http://schemas.microsoft.com/sharepoint/v3"/>
The other option "UserSelectionMode" is also not documented. Now it is in a forum's post ;)
By the way, I found the XML-structure of list definitions. So if you want to know, how a list definition done via SharePoint UI is done in CAML, take a look into the content-database of the web application, table dbo.AllLists, pick the list, where you want to get the definition and copy the content of the field tp_Fields into an XML-editor .... there it is. Hi,
I applied exactly your solution in my WSS 3.0 but I still can not select more than one person in Vertreter field with following msg: You are only allowed to enter one item.
Pls show me your exact code or any more step I have to take?
Thanks very much.
- Often, I had to delete the list and reinstall the feature again, when I made changes to existing fields. Did you try that?
Thank for your reply. I have reinstalled feature, restart iis and then recreate list but the result is still the same.
I also cretated a content type with a UserMulti field but still can not to input multi user to this field. Here is my work:
I created a content type named 'MyContentType':
1. MyContentType.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- _filecategory="ContentType" _filetype="Schema" _filename="contenttype.xml" _uniqueid="e68b4af3-8f33-4248-a961-9bf1d5ed2498" -->
<ContentType ID="0x010100c13b332e590c4f54ba69c02326d531bb"
Name="MyContentType" Group="Development" Description="Developing Content Type" Version="0"><
FieldRefs><
FieldRef ID="{1950a668-18b0-4d7c-895d-6aa9888f49cc}" Name="MyContentTypeField" /></
FieldRefs></
ContentType></Elements>
The field with ID of "{1950a668-18b0-4d7c-895d-6aa9888f49cc}" in MyContentntType.xml is declared in MyContentType.Fields.xml below:
2. MyContentType.Fields.xml
xml version="1.0" encoding="utf-8"?><?
<
Elements xmlns="http://schemas.microsoft.com/sharepoint/">
_filecategory="ContentType" _filetype="File" _filename="fields.xml" _uniqueid="1950a668-18b0-4d7c-895d-6aa9888f49cc" --><!--
<
Field ID="{1950a668-18b0-4d7c-895d-6aa9888f49cc}" Name="MyContentTypeField" DisplayName="MyContentType Field" StaticName="MyContentTypeField" BaseType="Text" Type="UserMulti" Sealed="TRUE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInListSettings="TRUE" UserSelectionMode="PeopleOnly" SourceID="http://schemas.microsoft.com/sharepoint/v3"/></
Elements>In my Visual studio IDE tool appear a warning in UserSelectionMode="PeopleOnly" line:
Warning 1: The 'UserSelectionMode' attribute is invalid - The value 'PeopleOnly' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:int' - The string 'PeopleOnly' is not a valid Int32 value. D:\SharePointProjects\SharePointSolution\ContentTypes\MyContentType\MyContentType.Fields.xml
(if I ignore this warning and try to install this feature by stsadm -> appear 'The 'UserSelectionMode' attribute is invalid - The value 'PeopleOnly' is invalid according to its da
tatype 'http://www.w3.org/2001/XMLSchema:int' - The string 'PeopleOnly' is not a valid Int32 value.' ->fail to install the feature)When use a Reflector tool to deassemble Microsoft.SharePoint.dll, I found that: PeopleOnly = 0 and PeopleAndGroup = 1.
public enum SPFieldUserSelectionMode { PeopleOnly, PeopleAndGroups }
-> Then I replate UserSelectionMode="PeopleOnly" with UserSelectionMode="0" -> there is no warning anymore and the feature is successful installed. Be low is my feature.xml:
<?
xml version="1.0" encoding="utf-8"?>
Feature Id="{5337AE21-9650-4dbb-BEBE-C0303F4FD2A6}" Title="My Content Type" Description="My test content type with UserMulti field" Version="12.0.0.0" Hidden="FALSE" Scope="Site" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/" ><
<
ElementManifests><
ElementManifest Location="MyContentType.Fields.xml"/><
ElementManifest Location="MyContentType.xml"/></
ElementManifests></
Feature>Now my content type is successfully to install:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES>stsadm -o
installfeature -filename MyContentType\feature.xmlOperation completed successfully.
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES>stsadm -o
activatefeature -filename MyContentType\feature.xml -url http://namnvpc:18080Operation completed successfully.
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES>iisresetAttempting stop...
Internet services successfully stopped
Attempting start...
Internet services successfully restartedBut when I created a Document list of this new content type -> MyContentType field is still accept only one single user
Could you create 3 xml files by copy from here and deploy in to your WSS to test for me?
Thanks so much.
Hi,
Just wondering, has anyone resolved this issue? I've the same problem where I'm installing a custom list with a "UserMulti" field, but I'm ending up with the "You are only allowed to enter one item." message.
Thanks!
hi
im having the same problem. has anyone found a solution?
thanks
I had the same problem.
It turned out to be the schema.Have you checked the entry for your user field?
It should look something like this:
<Field ID="{guid}"
Name="Users"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="Users"
Group="MyGroup"
Type="UserMulti"
UserSelectionMode="0"
UserSelectionScope="0"
Mult="TRUE"
List="UserInfo"
DisplayName="Users"
Sortable="TRUE"
Description="Users"
Sealed="TRUE"
ColName="int1"
RowOrdinal="0" />
UserSelectionMode: 0 is for PeopleOnly, 1 is for PeopleAndGroups
UserSelectionScope: 0 is for all users. If you need to limit it to a certain SharePoint group, you must pick up the id for this group, which is an integer. I used the listgenerator from the SharePoint Solution Generator for this.
/Bisbjerg
I was having the same problem.
I tried the solution, but still it wasn't working.
Then I try to add an other field called Users to my list using the WSS list Settings.
Then suddenly the option allow multiple selection was visible.
This is what appeared on my screen:
This is the CAML that was generated by WSS itself:Allow multiple selections: 

Earlier versions of client programs might not support a Person or Group field that allows multiple selections. Adding this field might block those programs from saving documents to this library.
<
Field Type="UserMulti" DisplayName="Users" List="UserInfo" Required="FALSE" ShowField="ImnName" UserSelectionMode="PeopleAndGroups" UserSelectionScope="0" ID="{0cd8436f-2f38-48a4-81aa-d0beeb08d257}" SourceID="{2d164f99-f51f-481e-9c3a-82a55208842e}" StaticName="Users" Name="Users" ColName="int1" RowOrdinal="0" Group="" Mult="TRUE" Sortable="FALSE" Version="1"/>
I guess changing the field to UserMulti triggered something that allows multipl. I find it unexpected and strange. The functionality described in these posts is present by default in WSS apparently?
More on this:
http://www.dailycode.net/blog/post/Multiple-users-field.aspx
MD : www.dailycode.net
- 已编辑TheRave 2008年9月9日 10:00Added sig
- Try
Mult="TRUE"
for multiple User in SiteColumn
Saurabh@cleardevelop.com- 已建议为答案Alok.Pagariya 2009年7月20日 12:43
- 已编辑Saurabh Barmota 2008年11月26日 12:40mistaken
- Mult="TRUE" worked for me.
- Mult="TRUE" worked for me too

