locked
Why trigger another plugin? RRS feed

  • Question

  •  var primaryEnt = svcContext.CreateQuery("entity").Where(e => e[m_Parameters[1]] == entity[m_Parameters[1]]).FirstOrDefault();
                        primaryEnt["amount"] = amount;
                        svcContext.UpdateObject(primaryEnt);
                        svcContext.SaveChanges();

    I using this code to update one entity with amount, but it always trigger another plugin based on another filed(not amount).

    Anybody knows what happen?


    Awen

    Wednesday, November 5, 2014 8:28 AM

Answers

  •  //m_TracingService.Trace("Query primary entity");
                        //var primaryEnt = svcContext.CreateQuery(m_Parameters[2]).Where(e => e[m_Parameters[1]] == entity[m_Parameters[1]]).FirstOrDefault();
                        //primaryEnt[m_Parameters[3]] = amount;
                        //svcContext.UpdateObject(primaryEnt,false);
                        //svcContext.SaveChanges();

                        var primaryEnt = adminService.Retrieve(m_Parameters[2], ((EntityReference)entity[m_Parameters[1]]).Id, new ColumnSet(new string[] { m_Parameters[3] }));
                        primaryEnt[m_Parameters[3]] = amount;
                        adminService.Update(primaryEnt);

    I changed the entity query, it is ok now.


    Awen

    • Marked as answer by Awen Hu Wednesday, November 5, 2014 9:50 AM
    Wednesday, November 5, 2014 9:50 AM

All replies

  • Hi,

    Have you had a look at which fields that trigger the other plugin?

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, November 5, 2014 8:32 AM
  • yes, another field trigger it, not this "amount",.

    Awen

    Wednesday, November 5, 2014 8:34 AM
  • In that case it shouldn't trigger and it's sort of hard saying why with the information at hand, sorry.

    One thing you can look at is going through the attributes of the object you're updating if you have more fields inte the property bag.

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, November 5, 2014 8:38 AM
  •  //m_TracingService.Trace("Query primary entity");
                        //var primaryEnt = svcContext.CreateQuery(m_Parameters[2]).Where(e => e[m_Parameters[1]] == entity[m_Parameters[1]]).FirstOrDefault();
                        //primaryEnt[m_Parameters[3]] = amount;
                        //svcContext.UpdateObject(primaryEnt,false);
                        //svcContext.SaveChanges();

                        var primaryEnt = adminService.Retrieve(m_Parameters[2], ((EntityReference)entity[m_Parameters[1]]).Id, new ColumnSet(new string[] { m_Parameters[3] }));
                        primaryEnt[m_Parameters[3]] = amount;
                        adminService.Update(primaryEnt);

    I changed the entity query, it is ok now.


    Awen

    • Marked as answer by Awen Hu Wednesday, November 5, 2014 9:50 AM
    Wednesday, November 5, 2014 9:50 AM