update n create using plugin crm RRS feed

  • Question

  • while updating my account i have to create a new contact record.i have reg my plugin in account update.but i show me the error as 

    "plugin execution error".this is my code my target entity is "account" while updating the account following occur,(plugin message-update,entity-account)

     try                {
                        entity.Attributes["fax"] = "123";
                        Entity followup = new Entity("contact");
                            followup.Attributes["parentcustomerid"] = new EntityReference("account", entity.Id);
                            followup.Attributes["lastname"] = "test from pl";
                        tracingService.Trace("FollowupPlugin: Creating the task activity.");
                        service.Create(followup);                }

    is it possible to call two services in same time.how to rectify it.

    Thursday, May 4, 2017 6:49 AM

All replies

  • Hi ,

    Why you are updating your entity again, try to commect below code and try.

    entity.Attributes["fax"] = "123";



    Thursday, May 4, 2017 12:06 PM
  • Hi you can add this:

    if (context.Depth > 1) { return; }

    in your plugin to avoid infinite loop in update.



    Thursday, May 4, 2017 3:07 PM
  • Hi,

    Remove the code service.Update(entity). Assuming you are on pre-update, you are calling the update twice, once in your code and then it will naturally update.

    The rest should work as coded.



    Wednesday, May 24, 2017 11:19 PM
  • Hi there,

    Can you provide bit more details?

    Which stage your plugin is registered?

    What is the detailed error message you get. You should be able to download the log.

    Does the account get updated at all??

    Complete plugin code will be useful to help you.

    Sachith Chandrasiri

    Thursday, May 25, 2017 10:46 PM