Priyojit Mondal
Priyojit Mondal

Reputation: 21

Check if a record has any attachment - Dynamics CRM

I need to write a plugin where I have to check if a particular record has any file attached.

When I remove any file from a record it gets soft deleted. I check Annotation table in SQL server, but is there any flag that denotes the entry is soft deleted or not?

Upvotes: 1

Views: 2007

Answers (1)

Nicknow
Nicknow

Reputation: 7234

Dynamics CRM 2011 does not have a soft-delete. When the record is deleted in CRM there is a DELETE executed on the SQL server, resulting in the record being removed.

In an annotation, which is the entity for Note, an attachment is stored as bas64 encoded text. If you delete an attachment on a Note it results in an UPDATE to the annotation entity setting the fields related to the attachment to null.

If you want to trigger a plugin when an attachment is deleted you need to look at the both the delete and update events on annotation. If you want to know if the annotations related to a particular entity has an attachment you need to query annotation entity where objectid matches the entity and filename is not null.

For emails and appointments attachments are stored in activitymimeattachment instead of annotation.

Upvotes: 2

Related Questions