0

Is it possible to move the uploaded document from a library to another library in different site collection using SharePoint designer workflow or Nintex workflow?

I tried Nintex workflow, but it only provides option to move document from one library to another library within same site collection. But I want to move it across site collection.

Is it possible using SharePoint designer or Nintex?

closed as off-topic by Benny Skogberg Mar 4 at 13:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

I think, We use the Remote event receivers for this.
1) Create a remote event receiver for the document library
2) Make sure that allow the app to make app-only calls to sharepoint is checked and the app has Tenant level control to write files enter image description here
3). use the below code in the remove event receiver to copy the document

 string filePath = "/sites/dev/Copy/TypeScript_Succinctly.pdf";
        var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
        using (var sourceContext = spContext.CreateUserClientContextForSPHost())
        {
            Microsoft.SharePoint.Client.File sourceFile = sourceContext.Web.GetFileByServerRelativeUrl(filePath);
            //file stream will be used to upload in destination library
            var fileStream = sourceFile.OpenBinaryStream();
            sourceContext.Load(sourceFile, k => k.ServerRelativeUrl, k => k.Name);
            sourceContext.ExecuteQuery();
            //generate destination context
            string destinationSiteUrl = "https://tarun.sharepoint.com/sites/dev1";
            Uri destinationSiteUri = new Uri(destinationSiteUrl);
            //target realm of the tenant (This is constant per tenant)
            string targetRealm = TokenHelper.GetRealmFromTargetUrl(destinationSiteUri);
            //generate access token for destination site
            string accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, destinationSiteUri.Authority, targetRealm).AccessToken;
            //get destination site context using access token
            using (var destinationContext = TokenHelper.GetClientContextWithAccessToken(destinationSiteUrl, accessToken))
            {
                //load server relative url of destination library
                var destinationLibrary = destinationContext.Web.Lists.GetByTitle("Paste");
                FileCreationInformation fileCreationInfo = new FileCreationInformation();
                fileCreationInfo.ContentStream = fileStream.Value;
                fileCreationInfo.Url = sourceFile.Name;
                fileCreationInfo.Overwrite = false;
                Microsoft.SharePoint.Client.File destinationFile = destinationLibrary.RootFolder.Files.Add(fileCreationInfo);
                destinationContext.Load(destinationFile, k => k.ServerRelativeUrl);
                destinationContext.ExecuteQuery();
                lbl_Success.Text = "Copied Sucessfully";
            }
        }
0

Try using open to explorer option which works in IE. Open both library location in IE, click open to explorer under libraries above , once it opens copy and just paste it in the desired library.

  • thanks, I want this to happen whenever document is uploaded to a library – Vignesh Subramanian Apr 17 '17 at 9:18

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