1

I am working on a remote event receiver inside SharePoint online, and i have a code to move a folder to another library. now the source and destination libraries have the same content type and each library contain 5 managed metadata columns. now i want to move FolderA from lib1 to lib2, so i try the follow:-

Folder folder = context.Web.GetFolderByServerRelativeUrl(context.Web.ServerRelativeUrl + "/lib1/" + currentFilingSystemItem["DealName"].ToString());
folder.MoveTo(context.Web.ServerRelativeUrl + "/lib2/" );

But this will raise an error that it can not rename FolderA to lib2, folder already exists, so seems i need to add the FolderA name inside the destination path, so i tried the following:-

 Folder folder = context.Web.GetFolderByServerRelativeUrl(context.Web.ServerRelativeUrl + "/lib1/" + currentFilingSystemItem["DealName"].ToString());
 folder.MoveTo(context.Web.ServerRelativeUrl + "/lib2/"+ currentFilingSystemItem["DealName"].ToString());

this has moved the folder, but the main folder FolderA will lost its managed metadata values, while the MoveTo has preserve the managed metadata for the sub-folders and files. can anyone advice if i can force the MoveTo to preserve the managed metadata for the main folder as well?

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.