我正在尝试将值推送到SharePoint Online列表中。 几个问题:
SPFieldType
和FieldType
之间存在一些巨大差异,或者代码会自动进行更改吗?FieldType
中,我正在寻找一些参考或代码来解释各种字段类型的正确映射。我已经在姐妹产品SharePoint 2013中看到了这些内容,例如:但2013 SPFieldType
和Microsoft.SharePoint.Client.FieldType
之间的差异似乎相当大。是否有相应的内容描述了每个字段类型在FieldType
?
以下是我现有代码的示例,以及我仍然缺少的内容:
public string ToString(Microsoft.SharePoint.Client.FieldType ColumnType)
{
switch (ColumnType)
{
case Microsoft.SharePoint.Client.FieldType.Boolean:
// 0 or 1, or "true" or "false"???
break;
case Microsoft.SharePoint.Client.FieldType.Calculated:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.Choice:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.Computed:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.Currency:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.DateTime:
return GetDateTimeValue().ToString("yyyy-MM-dd");
case Microsoft.SharePoint.Client.FieldType.File:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.GridChoice:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.Guid:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.Integer:
return GetIntValue().ToString();
case Microsoft.SharePoint.Client.FieldType.Lookup:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.MultiChoice:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.Note:
return GetStringValue();
case Microsoft.SharePoint.Client.FieldType.Number:
return GetDoubleValue().ToString();
case Microsoft.SharePoint.Client.FieldType.Text:
return GetStringValue();
case Microsoft.SharePoint.Client.FieldType.User:
// No idea!
break;
case Microsoft.SharePoint.Client.FieldType.URL:
// No idea!
break;
// No Idea what to do for these
case Microsoft.SharePoint.Client.FieldType.WorkflowEventType:
case Microsoft.SharePoint.Client.FieldType.WorkflowStatus:
case Microsoft.SharePoint.Client.FieldType.AllDayEvent:
case Microsoft.SharePoint.Client.FieldType.Attachments:
case Microsoft.SharePoint.Client.FieldType.ThreadIndex:
case Microsoft.SharePoint.Client.FieldType.Threading:
case Microsoft.SharePoint.Client.FieldType.PageSeparator:
case Microsoft.SharePoint.Client.FieldType.Recurrence:
case Microsoft.SharePoint.Client.FieldType.Invalid:
case Microsoft.SharePoint.Client.FieldType.ContentTypeId:
case Microsoft.SharePoint.Client.FieldType.Counter:
case Microsoft.SharePoint.Client.FieldType.CrossProjectLink:
case Microsoft.SharePoint.Client.FieldType.MaxItems:
case Microsoft.SharePoint.Client.FieldType.ModStat:
case Microsoft.SharePoint.Client.FieldType.Error:
break;
default:
return GetStringValue();
}
return GetStringValue();
}
缺少的方法只是将数据中的值转换为适当的字符串。
答案 0 :(得分:1)
服务器对象模型和.NET客户端对象模型不同。 如果您想将值推送到SharePoint Online List,我建议您使用Pnp-PowerShell来实现它。
关于字段类型,请检查GetField中的代码。
如果您不想使用Pnp-PowerShell,则需要将服务器对象模型代码转换为客户端对象模型代码。