Microsoft KB Archive/878436

= How to change the sample code in the Microsoft CRM SDK to upload and download an attachment to a Sales Literature Item or Email Activity. =

PSS ID Number: 878436

Article Last Modified on 5/6/2005

-

The information in this article applies to:

 Microsoft Business Solutions CRM Software Development Kit (SDK), when used with:  Microsoft Business Solutions CRM 1.2

 Microsoft Business Solutions CRM 1.0 

-



TechKnowledge Content
SUMMARY

This article documents the changes needed to be made to the &quot;Uploading and Downloading an Attachment to a Note&quot; sample code in the How To section of the Microsoft CRM SDK. Use the code to upload or download an attachment associated with a Sales Literature Item or E-mail Activity.

MORE INFORMATION

There are three changes that must be made in the NoteUpload.htm file.

1. Each entity has its own .srf file. For Sales Literature Items, change the action in the form element to the following:

http://myservername/MSCRMSERVICES/SalesLiteratureItemUpload.srf

For E-mail Activities, change the action in the form element to the following:

http://myservername/MSCRMSERVICES/ActivityAttachmentUpload.srf.

2. The AttachmentType represents the objecttypecode of the entity the attachment is being associated with. The attachment type for Sales Literature Items must be changed to 1070 and for an E-mail Activity it must be set to 1001.

3. The attachment id corresponds to that of the Sales Literature Item id or the Activity Mime Attachment id and should be changed to represent that value.

Here is an adjusted NoteUpload.htm file, the items changed are in bold:

Note Upload





 <input type=&quot;hidden&quot; name=&quot;AttachmentId&quot; value=&quot;{238DF309-1A8B-4L73-A97Z-B3B33E9AE73B}&quot;>

<input type=&quot;hidden&quot; name=&quot;UserId&quot; value=&quot;{38321ABC-6994-3280-G333-1U871038LE29}&quot;>

<input type=&quot;hidden&quot; name=&quot;MerchantId&quot; value=&quot;{C59799EE-412C-4096-B60C-FA1AD13AA4CB}&quot;>

<input type=&quot;hidden&quot; name=&quot;ErrorURL&quot; value=&quot; http://myservername/AttachmentHelpers/error.htm&quot;>

<input type=&quot;hidden&quot; name=&quot;SuccessURL&quot; value=&quot; http://myservername/AttachmentHelpers/NoteDownload.htm&quot;>

<input type=&quot;File&quot; name=&quot;userFile&quot; size=&quot;20&quot;> <input type=&quot;submit&quot; name=&quot;UPL&quot; value=&quot;Submit&quot;>

There are three changes that must be made in the NoteDownload.htm file.

1. Each entity has its own .srf file. For Sales Literature Items, the action in the form element must be changed to http://myservername/MSCRMSERVICES/SalesLiteratureItemUpload.srf?. For E-mail Activities, the action in the form element must be changed to http://myservername/MSCRMSERVICES/ActivityAttachmentUpload.srf?.

2. The AttachmentType represents the objecttypecode of the entity the attachment is being associated with. The attachment type for Sales Literature Items needs to be set to 1070 and for an E-mail Activity it must be set to 1001. In the NoteDownload.htm file the AttachmentType value is followed by the ampersand.

3. The attachment id corresponds to that of the Sales Literature Item id or the Activity Mime Attachment id and should be changed to represent that value. In the NoteDownload.htm file, the AttachmentId is formatted as follows:

AttachmentId=%7B %7D&

Here is an adjusted NoteDownload.htm file, the items changed are in bold:

Note Download

<body alink=&quot;#0000ff&quot; vlink=&quot;#0000ff&quot; bgcolor=&quot;#ffffff&quot;>

<A HREF=&quot;

http://myservername/MSCRMSERVICES/NoteDownload.srf?AttachmentType=5&AttachmentId=%7B16274GPF-3F74-4W64-ME84-CACC3E3AX78B%7D&UserId=%7B38321ABC-6994-3280-G333-1U871038LE29%7D&MerchantId=%7BC59799EE-412C-4096-B60C-FA1AD13AA4CB%7D&ErrorURL=http://myservername/AttachmentHelpers/error.htm&FileName=NoteFile.txt&quot;>

Download!</A>

The Sales Literature Item can be created using the CRMSalesLiteratureItem.Create Method and the Activity Mime Attachment can be created using the CRMActivityAttachment.Create Method. The return value of these methods is the id needed for the attachment id in the .htm files.

REFERENCES

For more information about CRMActivityAttachment.Create method

Version 1.0: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk/htm/crmactivityattachmentcreatemethod.asp

Version 1.2: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk1_2/htm/v1d2crmactivityattachmentcreatemethod.asp

For more information about CRMSalesLiteratureItem.Create method

Version 1.0: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk/htm/crmsalesliteratureitemcreatemethod.asp

Version 1.2: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk1_2/htm/v1d2crmsalesliteratureitemcreatemethod.asp

Use this link to review the documentation in the Microsoft CRM SDK about the Uploading and Downloading an Attachment to a Note:

Version 1.0: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk/htm/uploadordownloadanattachmenttoanote.asp

Version 1.2: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk1_2/htm/v1d2uploadordownloadanattachmenttoanote.asp

This article was TechKnowledge Document ID: 35457

Keywords: kbMBSMigrate KB878436

Technology: kbBizSolSearch kbCRM kbCRMSDK kbCRMSearch

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.