0

I need to find all "attachment" (A) records that are not referenced by an "activitymimeattachment" (AMA) record. If these 2 records are related, the Id of the A record is stored in the "attachmentid" attribute of the AMA record.

I can find all As that ARE referenced by an AMA with this query:

    QueryExpression BLOBQuery = new QueryExpression("attachment");
    LinkEntity link = new LinkEntity("attachment", "activitymimeattachment", "attachmentid", "attachmentid", JoinOperator.Inner);
    BLOBQuery.LinkEntities.Add(link);

and grouping, selecting first to get unique results based on Id

Is the opposite possible with any crm query mechanism? Linking seems to be irrelevant as it's anti-linking I want...

I can iterate thru all my A's and check if each one is referenced or not but I have a lot of them and it could run for at least a day.

keerz
  • 717
  • 1
  • 6
  • 21
  • I take is attachment is a custom entity here, and not the annotation entity (which by default has a name of annotation)? – James Wood Sep 30 '12 at 17:57
  • @James no, the "attachment" entity is the crm entity used to store file BLOBs i.e. email attachments – keerz Oct 01 '12 at 06:06
  • O I see, I was getting mixed up with the annotation entity. – James Wood Oct 01 '12 at 08:40
  • a bit more info. it appears that files in crm can manifest in 2 ways. if a file is associated with an activity, that is represented in crm as an activitymimeattachment + attachment record. If a file is inserted in crm in some other way it seems to be represented as a note (logical name annotation). The file contents + metadata are part of the annotation record itself in contrast to the activity file which is captured by a combo of the 2 records mentioned earlier. It is the activity files I am after. – keerz Nov 15 '12 at 04:02

0 Answers0