开发者

Programatically retrieve an attachment stored on a note on a CRM 4.0 entity

How would you suggest working with files that is stored on the note of a entity in Crm. Could you write a generic method that will enable you to access any type of file? Or would it be better to have a 开发者_运维知识库method for dealing with each type of file?

For example, we are going to be saving a mix of swf files and xml files on the entity, so would it make sense to have a method each for example:

  • GetXmlFilesOnAccount(accountid)
  • GetSwfFilesOnAccount(accountid)


When you upload an attachment to CRM the mimetype is also saved as part of the record information. The following link contains a nice example of how to download the attachemt using a single method. http://crmscape.blogspot.com/2009/10/ms-crm-40-sending-attachments-to.html

The post is missing the actual query needed to retrieve the annotations but you can tell what columns are required from the method signature.


My suggestion using your methods:

* GetXmlFilesOnAccount(accountid)
* GetSwfFilesOnAccount(accountid)
  1. Retrieve account activitypointers by regardingobjectid(in your case accountid guid)
  2. Loop through returned activitypointers
  3. Get attachments for each activitypointer (activitypointer.activityid = activitymimeattachment.activityid)
  4. Store attachments (disk, etc)

You don't even need two methods. You can retrieve all attachment file types for a given note (annotation) with a single method.

Hope this helps.


I recently started an Open Source Project on CodePlex to accomplish exactly that. Feel free to check out the Project's Web Page at:

http://crmattachdownload.codeplex.com/

You can also view the source code under the "Source Code" tab of that same page.

Pete

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜