使用以下代码使用c#
在sharepoint中设置字段值using (Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite("http://soweto:5000/sites/SPDWF_Issue"))
{
using (Microsoft.SharePoint.SPWeb web = site.OpenWeb())
{
Microsoft.SharePoint.SPList list = web.Lists["Cust"];
Microsoft.SharePoint.SPListItem item = list.Items.Add();
SPFieldMultiLineText actionField =
item.Fields.GetFieldByInternalName("Action")
as SPFieldMultiLineText;
item["Action"] = actionField.GetFieldValueAsText("<Action ActionType=\"Metalogix.SharePoint.Actions.Migration.PasteListAction, Metalogix.SharePoint.Actions, Version=8.3.0.3, Culture=neutral, PublicKeyToken=3b240fac3e39fc03\"><CopyListPermissions Type=\"System.Boolean\">False</CopyListPermissions><FilterLists Type=\"System.Boolean\">False</FilterLists><ListFilterExpression Type=\"Metalogix.Data.Filters.IFilterExpression\"><And IsImplicitGroup=\"True\" /></ListFilterExpression><OverwriteLists Type=\"System.Boolean\">False</OverwriteLists><UpdateLists Type=\"System.Boolean\">False</UpdateLists><OverwriteFolders Type=\"System.Boolean\">False</OverwriteFolders><UpdateListOptionsBitField Type=\"System.Int32\">0</UpdateListOptionsBitField><CheckModifiedDatesForLists Type=\"System.Boolean\">True</CheckModifiedDatesForLists><CopyCustomizedFormPages Type=\"System.Boolean\">False</CopyCustomizedFormPages><CopyListOOBWorkflowAssociations Type=\"System.Boolean\">False</CopyListOOBWorkflowAssociations><CopyWebOOBWorkflowAssociations Type=\"System.Boolean\">False</CopyWebOOBWorkflowAssociations><CopyContentTypeOOBWorkflowAssociations Type=\"System.Boolean\">True</CopyContentTypeOOBWorkflowAssociations><CopyListSharePointDesignerNintexWorkflowAssociations Type=\"System.Boolean\">True</CopyListSharePointDesignerNintexWorkflowAssociations><CopyWebSharePointDesignerNintexWorkflowAssociations Type=\"System.Boolean\">False</CopyWebSharePointDesignerNintexWorkflowAssociations><CopyContentTypeSharePointDesignerNintexWorkflowAssociations Type=\"System.Boolean\">True</CopyContentTypeSharePointDesignerNintexWorkflowAssociations><CopyNintexDatabaseEntries Type=\"System.Boolean\">False</CopyNintexDatabaseEntries><CopyPreviousVersionOfWorkflowInstances Type=\"System.Boolean\">False</CopyPreviousVersionOfWorkflowInstances><CopyGloballyReusableWorkflowTemplates Type=\"System.Boolean\">False</CopyGloballyReusableWorkflowTemplates><CopyViewWebParts Type=\"System.Boolean\">False</CopyViewWebParts><CopyFormWebParts Type=\"System.Boolean\">False</CopyFormWebParts><FilterFolders Type=\"System.Boolean\">False</FilterFolders><FolderFilterExpression Type=\"Metalogix.Data.Filters.IFilterExpression\"><And IsImplicitGroup=\"True\" /></FolderFilterExpression><CopyFolderPermissions Type=\"System.Boolean\">False</CopyFolderPermissions><UpdateFolderOptionsBitField Type=\"System.Int32\">0</UpdateFolderOptionsBitField><CopyListItems Type=\"System.Boolean\">True</CopyListItems><UseAzureOffice365Upload Type=\"System.Boolean\">True</UseAzureOffice365Upload><EncryptAzureMigrationJobs Type=\"System.Boolean\">True</EncryptAzureMigrationJobs><CopyDocumentWebParts Type=\"System.Boolean\">True</CopyDocumentWebParts><CopyClosedWebParts Type=\"System.Boolean\">False</CopyClosedWebParts><CopyContentZoneContent Type=\"System.Boolean\">True</CopyContentZoneContent><ExistingWebPartsAction Type=\"Metalogix.SharePoint.Options.Migration.ExistingWebPartsProtocol\">Delete</ExistingWebPartsAction><CopyWebPartsAtItemsLevel Type=\"System.Boolean\">True</CopyWebPartsAtItemsLevel><CopyDefaultPageWebPartsAtItemsLevel Type=\"System.Boolean\">True</CopyDefaultPageWebPartsAtItemsLevel><FilterItems Type=\"System.Boolean\">False</FilterItems><FilterFields Type=\"System.Boolean\">False</FilterFields><ItemFilterExpression Type=\"Metalogix.Data.Filters.IFilterExpression\" /><ListFieldsFilterExpression Type=\"Metalogix.Data.Filters.IFilterExpression\"><And IsImplicitGroup=\"True\" /></ListFieldsFilterExpression><RenameSpecificNodes Type=\"System.Boolean\">False</RenameSpecificNodes><TaskCollection Type=\"Metalogix.DataStructures.TransformationTaskCollection\"><TransformationTaskCollection /></TaskCollection><MapColumns Type=\"System.Boolean\">False</MapColumns><ColumnMappings Type=\"Metalogix.SharePoint.Options.Migration.Mapping.ColumnMappings\"><ColumnMappingsList AutoMapCreatedAndModified=\"False\"><FieldsFilter><And IsImplicitGroup=\"True\" /></FieldsFilter><XmlableSet /></ColumnMappingsList></ColumnMappings><MapTermStores Type=\"System.Boolean\">False</MapTermStores><CopyRootPermissions Type=\"System.Boolean\">True</CopyRootPermissions><MapRolesByName Type=\"System.Boolean\">True</MapRolesByName><ClearRoleAssignments Type=\"System.Boolean\">True</ClearRoleAssignments><OverrideRoleMappings Type=\"System.Boolean\">False</OverrideRoleMappings><RoleAssignmentMappings Type=\"Metalogix.Data.ConditionalMappingCollection\"><XmlableSet /></RoleAssignmentMappings><CopyItemPermissions Type=\"System.Boolean\">False</CopyItemPermissions><ItemCopyingMode Type=\"Metalogix.SharePoint.Options.ListItemCopyMode\">Overwrite</ItemCopyingMode><UpdateItems Type=\"System.Boolean\">False</UpdateItems><CheckModifiedDatesForItemsDocuments Type=\"System.Boolean\">True</CheckModifiedDatesForItemsDocuments><UpdateItemOptionsBitField Type=\"System.Int32\">0</UpdateItemOptionsBitField><PropagateItemDeletions Type=\"System.Boolean\">False</PropagateItemDeletions><ReattachPageLayouts Type=\"System.Boolean\">False</ReattachPageLayouts><CopyVersions Type=\"System.Boolean\">True</CopyVersions><CopySubFolders Type=\"System.Boolean\">True</CopySubFolders><CopyMaxVersions Type=\"System.Boolean\">False</CopyMaxVersions><MaximumVersionCount Type=\"System.Int32\">1</MaximumVersionCount><PreserveItemIDs Type=\"System.Boolean\">True</PreserveItemIDs><PreserveDocumentIDs Type=\"System.Boolean\">True</PreserveDocumentIDs><PreserveSharePointDocumentIDs Type=\"System.Boolean\">False</PreserveSharePointDocumentIDs><ShallowCopyExternalizedData Type=\"System.Boolean\">False</ShallowCopyExternalizedData><DisableDocumentParsing Type=\"System.Boolean\">False</DisableDocumentParsing><ApplyNewContentTypes Type=\"System.Boolean\">True</ApplyNewContentTypes><ContentTypeApplicationObjects Type=\"Metalogix.DataStructures.Generic.CommonSerializableList`1[[Metalogix.SharePoint.Options.Migration.ContentTypeApplicationOptionsCollection, Metalogix.SharePoint.Options, Version=8.3.0.3, Culture=neutral, PublicKeyToken=3b240fac3e39fc03]]\" /><ApplyNewDocumentSets Type=\"System.Boolean\">False</ApplyNewDocumentSets><DocumentSetApplicationObjects Type=\"Metalogix.DataStructures.Generic.CommonSerializableList`1[[Metalogix.SharePoint.Options.Migration.DocumentSetApplicationOptionsCollection, Metalogix.SharePoint.Options, Version=8.3.0.3, Culture=neutral, PublicKeyToken=3b240fac3e39fc03]]\" /><FolderToDocumentSetApplicationObjects Type=\"Metalogix.DataStructures.Generic.CommonSerializableList`1[[Metalogix.SharePoint.Options.Migration.DocumentSetFolderOptions, Metalogix.SharePoint.Options, Version=8.3.0.3, Culture=neutral, PublicKeyToken=3b240fac3e39fc03]]\" /><CopyWorkflowInstanceData Type=\"System.Boolean\">False</CopyWorkflowInstanceData><CopyInProgressWorkflows Type=\"System.Boolean\">False</CopyInProgressWorkflows><ResolveManagedMetadataByName Type=\"System.Boolean\">False</ResolveManagedMetadataByName><CopyReferencedManagedMetadata Type=\"System.Boolean\">False</CopyReferencedManagedMetadata><TermstoreNameMappingTable Type=\"Metalogix.DataStructures.Generic.CommonSerializableTable`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]\"><XmlableTable /></TermstoreNameMappingTable><SideLoadDocuments Type=\"System.Boolean\">False</SideLoadDocuments><MigrationMode Type=\"Metalogix.SharePoint.Options.MigrationMode\">Full</MigrationMode><MapAudiences Type=\"System.Boolean\">False</MapAudiences><Verbose Type=\"System.Boolean\">False</Verbose><LogSkippedItems Type=\"System.Boolean\">False</LogSkippedItems><CheckResults Type=\"System.Boolean\">False</CheckResults><CompareOptions Type=\"Metalogix.DataStructures.ComparisonOptions\"><ComparisonOptions ComparisonLevel=\"Moderate\" /></CompareOptions><ForceRefresh Type=\"System.Boolean\">True</ForceRefresh><CorrectingLinks Type=\"System.Boolean\">True</CorrectingLinks><LinkCorrectTextFields Type=\"System.Boolean\">False</LinkCorrectTextFields><LinkCorrectionScope Type=\"Metalogix.SharePoint.Migration.LinkCorrectionScope\">SiteCollection</LinkCorrectionScope><UseComprehensiveLinkCorrection Type=\"System.Boolean\">False</UseComprehensiveLinkCorrection><AllowDBUserWriting Type=\"System.Boolean\">False</AllowDBUserWriting><MapGroupsByName Type=\"System.Boolean\">True</MapGroupsByName><OverwriteGroups Type=\"System.Boolean\">True</OverwriteGroups><MapMissingUsers Type=\"System.Boolean\">False</MapMissingUsers><MapMissingUsersToLoginName Type=\"System.String\" /><PersistMappings Type=\"System.Boolean\">False</PersistMappings><OverrideCheckouts Type=\"System.Boolean\">True</OverrideCheckouts><IsFromAdvancedMode Type=\"System.Nullable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]\" /><TelemetryLogs Type=\"System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]\" /><EmailServer Type=\"System.String\" /><EmailUserName Type=\"System.String\" /><EmailPassword Type=\"System.String\" /><ToEmailAddress Type=\"System.String\" /><FromEmailAddress Type=\"System.String\" /><CCEmailAddress Type=\"System.String\" /><BCCEmailAddress Type=\"System.String\" /><EmailSuccessTemplateFilePath Type=\"System.String\" /><EmailFailureTemplateFilePath Type=\"System.String\" /><EmailSubject Type=\"System.String\" /><SendEmail Type=\"System.Boolean\">False</SendEmail><Transformers Type=\"Metalogix.Transformers.TransformerCollection\"><TransformerCollection /></Transformers><EnableSslForEmail Type=\"System.Boolean\">False</EnableSslForEmail></Action>");
item.Update();
}
}
然而,它将错误的值设置为FalseFalse。如何在多行文本字段中保存正确的值
答案 0 :(得分:0)
试试这会帮助你
using (Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite("http://soweto:5000/sites/SPDWF_Issue"))
{
using (Microsoft.SharePoint.SPWeb web = site.OpenWeb())
{
Microsoft.SharePoint.SPList list = web.Lists["Cust"];
Microsoft.SharePoint.SPListItem item = list.Items.Add();
SPFieldMultiLineText multilineField = item.Fields.GetField("YourColumn") as SPFieldMultiLineText;
// Get the field value as HTML
string htmltext= multilineField.GetFieldValueAsHtml(item["YourColumn"], item);
//or Get the field as Text
string normaltext= multilineField.GetFieldValueAsText(item["YourColumn"]);
//updating html field text
htmltext+= "Hello I am being updated!";
item["YourColumn"] = htmltext;
item.Update();
}
}