2

I am using below command using JavaScript to copy a document in the same site in SharePoint Online. The file is copied successfully, but the associated metadata term values selected from my term set is not getting copied.

I am getting:

_sourceFile = this.currentItem.get_file();

And then later I am doing:

_sourceFile.copyTo(_destinationlibUrl, 1);

File is copied but not term values.

Can it be done in another way?

0

I have found an example here that is copying files between libraries:

var context = SP.ClientContext.get_current();
SP.MoveCopyUtil.copyFile(context,"http://sp2016/sitepages/home.aspx","http://sp2016/sitepages/home1.aspx");
context.executeQueryAsync(function(){},function(){});

It claims to copy the metadata as well.

3
  • Unfortunately it has the same behavior as with CopyTo, it only copies metadata with datatype Text, Datetime, Lookup, etc - not Managed Metadata term values from term set.
    – Xaphod
    Feb 11 '16 at 13:05
  • That's a pity. Out of curiosity, does it work when you use the interface to "Sent To" another location? Click on the file in the library and select the Documents tab. Locate "Send To", and select "Other Location" from the dropdown. I understand you're trying to programmatically achieve this, but if it works through the interface then I'm sure there must be a way to do it with code.
    – Ray Hogan
    Feb 11 '16 at 13:30
  • Yes, the "Send to > Copy" in the ribbon Files tab works for all metadata, including term values.
    – Xaphod
    Feb 13 '16 at 9:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.