Hi All,
I am facing a problem that seems fairly common so it could be simple for you guys.
I am creating a plugin on the email entity and I've registered it on the "create" and "update" event. What the plugin does is follows a set of logic and updates the body of the email. The plugin works fine on the update event but fails on the create.
The plugin is registered on the Post event so the entity already has all the info I need. What it does is applies the logic and then it fires a Update service call with the new body. However this fails for the "PostCreate" event because I can't seem to be able to obtain the Guid of the email in question. Bellow is a sniplet of the code that does it:
DynamicEntity entity =
(DynamicEntity)context.InputParameters.Properties["Target"];
string newBody;
// Here we populate the new body based on some logic.
email emailToUpdate = new email();
email.activityid = (Key)entity["activityid"];
email.description = newBody;
_service.Update(email);
Of course I do have a few checks in the start of the method to prevent infinite looping. As I said, this works for the Post Update event but fails on the PostCreate because "entity" does not have a property called "activityid".
Any thoughts or suggestions are most welcome.
Thanks in advance