locked
can't update email in email post save plugin? RRS feed

  • Question


  • Hello - I have plugin for email create. I get a handle to the email object in the plugin in the normal way and I'm able to access all of the expected email properties.

    As part of the email create logic, I create a case and then associate the email with the case by setting the email RegardingObjectId = case ID.

    Then I try to update the email object using the service context:  service.Update(email).

    I'm able to use the service in the same plugin to create a contact and case but I can't use the service to update the email object.  It returns a rather unhelpful FaultException: "An unexpected error occured."

    I also tried using the service at the very beginning to update the email object, right after I get the email object from the context, and I get the same unexpected error.  This tells me that the error does not have to do with setting a property on the email.

    If I get a handle to the current object in its post-save plugin, do I need to do something special with it in order to call the service.Update method on it? Based on this problem description can you figure out what I'm doing wrong here?
    Wednesday, July 17, 2013 12:33 AM

All replies

  • Hi There,

    make sure that when setting the regardingobjectid you are not simply assigning the GUID. you need to assign it to an entityreference.

    For example you want to set the contact as a regarding objectid you need to write like this,

    email["regardingobjectid"]=new EntityReference("contact",<guid of contact>);


    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful" Thank you, DT

    Wednesday, July 17, 2013 1:07 PM
  • Please post your code. Also add tracing to your plugin to see where it's crashing.
    Friday, July 19, 2013 11:35 AM