简体   繁体   English

使用Sharepoint客户端对象模型创建类型为user,multichoice和multiuser的站点列

[英]Create a site-column of type user, multichoice and multiuser using Sharepoint Client Object Model

I'm trying to create site-columns with following types: Text, Note, Number, Choice, User, MultiUser, MultiChoice 我正在尝试创建具有以下类型的站点列: 文本,注释,数字,选择,用户,多用户,MultiChoice

I've implemented it for all the types except for User, MultiChoice and MultiUser. 我已经为User,MultiChoice和MultiUser以外的所有类型实现了它 Can't seem to find how to achieve it. 似乎找不到实现该目标的方法。 This is what I've achieved so far. 这是我到目前为止所取得的成就。

StringBuilder choiceFieldGenericShema = new StringBuilder();
                choiceFieldGenericShema.Append("<Field Type='Choice' Format='Dropdown' Group='{1}' Name='{0}' DisplayName='{2}' Status='{3}' > <CHOICES> ");
                choiceFieldGenericShema.Append("</CHOICES>  </Field> ");
                string choicFieldSchema = string.Format(choiceFieldGenericShema.ToString(), columnItem.Title, columnItem.GroupName, columnItem.Name, columnItem.Status);
                var newField = web.Fields.AddFieldAsXml(choicFieldSchema, true, AddFieldOptions.DefaultValue);
                clientContext.Load(newField);
                clientContext.ExecuteQuery();

Can anyone please suggest a way following the above method to achieve my task? 有人可以建议一种遵循上述方法的方法来完成我的任务吗? Thanks in advance! 提前致谢!

I suggest you take a look at these articles: 我建议您看一下这些文章:

In this case, you'll need to tweak with some attributes to toggle multi select for a choice + user field: 在这种情况下,您需要调整一些属性以切换选择+用户字段的多选:

Choice: 选择:

<Field Type="MultiChoice" 
DisplayName="Labels_Selected" 
FillInChoice="FALSE" 
Group="Sample Site Columns" 
ID="{2fdf0ba7-0052-4e9f-80f6-e7669ac4ae4f}"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="LabelsSelected" Name="LabelsSelected"> 
</Field>

User: 用户:

<Field ID="{A0372EB5-A947-41CA-A5FA-A34C29D2FB88}"
Name="Employee"
DisplayName="Employee"
Type="UserMulti"
Required="TRUE"
StaticName="Employee"
UserSelectionMode="PeopleOnly"
Group="SampleGroup"/>

You can create site column using csom , below is code 您可以使用csom创建网站栏,以下为代码

string schemaChoiceField = "<Field ID='<GUID>' Type='Choice' Name='SideDishesChoice' StaticName='SideDishesChoice' 
   DisplayName='Side dishes' Format='RadioButtons'>"
   + "<Default>Patatoes</Default>"
   +         "<CHOICES>"
   +         "    <CHOICE>Fresh vegetables</CHOICE>"
   +         "    <CHOICE>Beans</CHOICE>"
   +         "</CHOICES>"
   + "</Field>";

For dropdown or radio button follow the link http://projectservercode.com/create-choice-type-site-column-using-csom-sharepoint/ 对于下拉菜单或单选按钮,请点击链接http://projectservercode.com/create-choice-type-site-column-using-csom-sharepoint/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Sharepoint Client模型中的内容类型中删除站点列引用 - How to delete a site-column reference from a content-type in Sharepoint Client model 无法使用Sharepoint客户端对象模型连接到Sharepoint网站 - Unable to connect to sharepoint site using Sharepoint Client Object Model 使用SharePoint客户端对象模型检查是否存在列表列? - Check if a List Column Exists using SharePoint Client Object Model? SharePoint列表:使用JavaScript客户端对象模型的列值总和 - SharePoint List : Sum of Column Values using JavaScript Client Object Model 使用客户端对象模型在SharePoint文档库上创建文件夹 - Create folder on SharePoint document library using client object model 使用Sharepoint 2013中的客户端对象模型更新元数据列 - Metadata column update using client object model in Sharepoint 2013 使用客户端对象模型在Sharepoint C#中创建ListItem - Create ListItem in Sharepoint C# Using Client-Object Model 使用Sharepoint 2010客户端对象模型搜索站点中以特定扩展名结尾的所有文档 - Search for all documents in a site that end with a specific extention using Sharepoint 2010 Client Object Model 使用共享点对象模型创建新的共享点站点时出错 - Error while creating a new sharepoint site using sharepoint object model 如何使用客户端对象模型从“AssignedTo”字段获取Sharepoint User对象? - How to get Sharepoint User object from the “AssignedTo” field using client side object model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM