4

I'm trying to provide a link to the attachment of a note through the client-side JScript. The standard MS-made Notes component does this through the following url:

[serverurl]/[appname]/Activities/Attachment/download.aspx?AttachmentType=5&AttachmentId={blahblahblah}&IsNotesTabAttachment=1&CRMWRPCToken=blahblahblah&CRMWRPCTokenTimeStamp=blahblahblah

The problem is that I don't know how to get the Token or TokenTimeStamp, so I'm receiving an Access Denied error ("form is no longer available, security precaution, etc").

The only other way I can think of doing this is through the OData endpoint, but that would at best get me a base64 string that I still would have translate into a filestream to give to the browser (all of which seems like it would take forever to implement/figure out).

I've found a few other posts that describe the same thing, but no one has answered them:

http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/6eb9e0d4-0c0c-4769-ab36-345fbfc9754f/

http://social.microsoft.com/Forums/is/crm/thread/45dabb6e-1c6c-4cb4-85a4-261fa58c04da

Peter Majeed
  • 5,304
  • 2
  • 32
  • 57
VVander
  • 308
  • 1
  • 4
  • 10
  • This is another link to a thread with the same problem, SO wouldn't let me post more than two links in the same question since I'm new. http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/6eb9e0d4-0c0c-4769-ab36-345fbfc9754f – VVander Jun 07 '12 at 19:56
  • Did you see this? http://msdn.microsoft.com/en-us/library/gg309401.aspx#OrganizationDataService There is a REST API for Dynamics CRM 2011. You should be able to connect directly. The documentation at that link will describe the necessary authentication and so on. – Cheeso Jun 15 '12 at 03:12
  • I did try to use an Odata query, but that didn't work since it returns binary information that couldn't be streamed to the browser for download through JScript (at least any way I know of - I tried all sorts of tricks). – VVander Jun 25 '12 at 21:05
  • that is surprising to me. It's possible to download binary data via Javascript + XMLHttpRequest, on any browser. The question is *what do you do with the data once it is downloaded*? That is where it gets tricky but it is still possible. – Cheeso Jun 26 '12 at 00:34
  • You'll find exactly what you need in the answer by Nicknow at https://stackoverflow.com/questions/21624351/how-to-get-programmaticallyvia-plugin-crmwrpctoken-crmwrpctokentimestamp-in/21689372#21689372 – Heckflosse_230 Mar 09 '15 at 19:27

1 Answers1

1

The download is strange within CRM 2011. I'm sure it's a security thing, but it's a lot of clicking.

Anyhow, I opted to create a "web service" which get's passed the annotation id. The web service goes out and gets the attachment and then modifies the response to send the proper file (PDF, jpg, etc.)

Paul Way
  • 1,966
  • 1
  • 13
  • 10
  • This is also what I ended up doing before I saw your answer. I wish that there was a better way, but this seems like the only way that can work. – VVander Jun 25 '12 at 21:03