{Dynamics CRM Web Resources} Show Attachments for an entity in Custom Webresource in Microsoft Dynamics CRM

Recently in our project we had a requirement where we needed the attachments for an entity in a custom webresource so that when the user clicks the attachment it downloads. For that first of all you would need to get the attachmentid by querying the annotations which are of type attachment for the entity. Once you have the attachmentid, you need to prepare the URL in the below format.

CRM 2011


Xrm.Page.context.getServerUrl() + “/Activities/Attachment/download.aspx?AttachmentType={AttachmentType}&IsNotesTabAttachment=1&AttachmentId={” + attachmentId + “}”;


CRM 2013


Xrm.Page.context.getClientUrl() + “/Activities/Attachment/download.aspx?AttachmentType={AttachmentType}&IsNotesTabAttachment=1&AttachmentId={” + attachmentId + “}”;

{AttachmentType} – It has to be specified based on the type of the attachment.

However once you click, you might get an error invalid_wrpc_token.

To overcome this you need to add a key to your registry

1. Go to HKEY_LOCAL_MACHINE -> Software -> Microsoft -> MSCRM in CRM App server

2. Create a new D-WORD ‘IgnoreTokenCheck’. Set value to 1.

3. Restart IIS in the CRM app server.


Browse to CRM again and you should be able to download the attachment clicking the URL.


Hope this helps!