web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

how to copy a file within sharepoint using a CRM plugin/workflow(C# server side code).

(0) ShareShare
ReportReport
Posted on by

Hi.

I am creating a CRM plugin(will later convert into a workflow, basically a C# server side code), that is supposed to copy an entity record changing a few fields along the way. now one of the fields i need to change is the sharepoint URL of a document. i know that simply changing the URL will lead to a file that does not exist. so i want my plugin to connect to sharepoint, "copy" a file located somewhere in sharepoint(known URL), and "patse" it to a new URL that is also known/i'll write it as needed. and only once that is done, change the "sharepoint URL" field of the record to the new URL(i know how to change entity record fields)

anyone has an idea on how to do this copy/patse operation? i tried to find an answer all over the internet and i saw some CRM/sharepoint connection things but none of them is what that i want to do

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    You'll need to use the SharePoint API for this. SharePoint has a few different versions of the API; one option is to use CopyIntoItemLocal method of the copy.asmx web service

  • Community Member Profile Picture
    on at

    i'll try to find the sharepoint API, do i need to upload it to CRM by any means?

  • Ben Thompson Profile Picture
    6,350 on at

    copy.asmx is a web service within sharepoint. Provided you can find the api documentation you should be able to perform the operation via a couple of https API calls from within your plugin...

  • Community Member Profile Picture
    on at

    there is that

    msdn.microsoft.com/.../websvccopy.copy.copyintoitemslocal.aspx

  • Suggested answer
    Ben Thompson Profile Picture
    6,350 on at

    Although this is Javascript rather than C# this does show you what the webapi request needs to look like

    See this link

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    The web APi equivalent for copy.asmx is copyto .

    sharepoint.stackexchange.com/.../how-to-copy-files-between-sites-using-rest-api-in-sharepoint-online

    This is the list of API methods available from SharePoint - docs.microsoft.com/.../working-with-folders-and-files-with-rest

    However, you need to first connect to SharePoint in order to execute any of these. You can use the sample code provided by Scott Durow - code.msdn.microsoft.com/SharePoint-Integration-c5f21604

    Hope this helps.

  • Kenneth Heiman Profile Picture
    45 on at

    Definitely the Sharepoint API will get you there, and is traditionally how we would approach this. Due to the limitations of the CRM sandbox as well as the nature of CRM Online, I've started leaning towards moving some of this kind of logic outside of CRM where it makes sense. For example you could try to leverage the Sharepoint connector in Flow/Logic apps to copy a file from location A to location B.  You would still be responsible for making a way to efficiently trigger the flow/logic app, depending on the exact situation, but Flow or Logic App would handle the actual movement of the file without any API coding. One (klugey) way you could trigger this is when your plugin fires and sees that the file needs to be copied, create a new CRM record in a 'FileCopyRequest' custom entity setting attributes for the old location and the new location, and the Flow would trigger on create of those records and copy the file accordingly.

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    I second Kenneth input.

    We were able to make the CRMOL + SPO integration successful, using SPO REST API calls from CRM plugins. The hardest part of authentication token, API calls everything went through. Able to test in own tenant.

    Finally we ended up in organization firewall & ADFS rule blockers, as the authentication calls were unable to be treated as coming from inside the corpnet. Our priorities changed as there are other Corporate tenant level changes happening.

    Once sorted out, we are having similar solution to do what Kenneth shared.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans