locked
CRM 2011 PLUGIN to update another entity RRS feed

  • Question

  • My PLUGIN is firing on Entity A and in my code I am invoking a web service that returns an XML file with some attributes (attr1,attr2,attr3 etc ...) for Entity B including GUID. I need to update Entity B using the attributes I received from the web service. Can I use Service Context Class (SaveChanges) or what is the best way to accomplish my task please? I would appreciate it if you provide an example.

    My PlugIn is firing on update in CRM 2011 On Premise.

    • Edited by Nick2020 Friday, December 6, 2013 2:53 PM
    Friday, December 6, 2013 2:27 PM

Answers

  • You can do a service.Retrieve of EntityB.

    Entity entityB = (Entity)service.Retrieve("<entity name>", entityB_Guid, new ColumnSet ( new string[] { "attr1","attr2","attr3" });

    Modify the attributes to those values from the XML and then do:

    Service.Update(entityB);

    • Proposed as answer by SteveGreen Friday, December 6, 2013 5:02 PM
    • Marked as answer by Nick2020 Friday, December 6, 2013 5:12 PM
    Friday, December 6, 2013 5:02 PM

All replies

  • Hello,

    You can create your entity object and use those attributes, and can use service object created from context to call update method.


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, December 6, 2013 3:48 PM
    Moderator
  • You can do a service.Retrieve of EntityB.

    Entity entityB = (Entity)service.Retrieve("<entity name>", entityB_Guid, new ColumnSet ( new string[] { "attr1","attr2","attr3" });

    Modify the attributes to those values from the XML and then do:

    Service.Update(entityB);

    • Proposed as answer by SteveGreen Friday, December 6, 2013 5:02 PM
    • Marked as answer by Nick2020 Friday, December 6, 2013 5:12 PM
    Friday, December 6, 2013 5:02 PM