none
CRM 2011 - Plugin - Associate message

    Question

  • I am trying to register a plugin on the Associate message for two entities with a many to many (N:N) relationship

    When I try and create a new step in the plugin registration tool I get the following error:

    "Invalid Primary Entity or Secondary Entity specified. Plese re-enter the data"

    I am trying to register against the Quote (quote) and a custom entity (new_equipment).

    Can you not specify the primary / secondary entities within the tool?

    Do I have to check the entities within code?

    How would I do this? 

    What does the context object look like when dealing with intersects?


    ePartners CRM
    Sunday, April 24, 2011 6:32 PM

Answers

  • I found it with:

     

    EntityReferenceCollection relatedentities = (EntityReferenceCollection)context.InputParameters["RelatedEntities"];
    
    if (relatedentities[0].LogicalName != "quote")
     return;
    
    EntityReference quote = new EntityReference("quote", new Guid(relatedentities[0].Id.ToString()));

    ePartners CRM
    • Marked as answer by ePartners UK Monday, April 25, 2011 9:29 PM
    Monday, April 25, 2011 9:29 PM

All replies

  • It seems "Associate" message is not available to register with Plugins. I have checked with "message-entity support for plug-ins.xlsx" file which comes with SDK. It has "NULL" values for both "PrimaryEntity" and "RelatedEntity" fileds which means we can't register "Associate" message with any of the entities.
    Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
    Sunday, April 24, 2011 7:39 PM
  • If I am in a Quote (quote) and associate an existing Equipment record (new_equipment), the Target object is the new_equipment entity reference.

    Can I use the Context object to get the GUIDs of both entities?

    How do I get a reference to the Quote entity?


    ePartners CRM
    Sunday, April 24, 2011 9:00 PM
  • Did you find an answer to this:  I am looking into this now.

    I think you can get the related entities by doing a retrievemultiplerequest on an sdkmessagerequestentity by the guid presented in your pluginexecutioncontext.requestid property.

    The sdkmessagerequest entity has a related entities property.  You should be able to iterate through these to get any info you want about the related entities, including information you would use to filter.  You could make sure for instance that there was both an entity with LogicalName of "account and one with logicalname = "contact" to determine if the associate request was between those two types before executing other actions. 

    The relatedentity enumerated objects should also have all the other properties of those entities (including Guids you could use to act on those objects).

     I can help you further on this one if you like.

    Make sense?

     


    Jamie Miley
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!

    Monday, April 25, 2011 9:26 PM
    Moderator
  • I found it with:

     

    EntityReferenceCollection relatedentities = (EntityReferenceCollection)context.InputParameters["RelatedEntities"];
    
    if (relatedentities[0].LogicalName != "quote")
     return;
    
    EntityReference quote = new EntityReference("quote", new Guid(relatedentities[0].Id.ToString()));

    ePartners CRM
    • Marked as answer by ePartners UK Monday, April 25, 2011 9:29 PM
    Monday, April 25, 2011 9:29 PM