11-30-2012 07:53 AM - edited 11-30-2012 09:54 AM
I am trying to wire up an assembly to validate zip code syntax for Canadian addresses.
I have started by overriding OnCreate, OnBeforeUpdate, and OnBeforeInsert. But it looks like OnCreate is being fired at strange times.
In my case, if I pull up an Account, and attempt to edit an already existing Address, the event is fired and I get an Object Reference exception, and all the Address' properties are empty - even if I put my custom event code in PreExecute.
If I remove OnCreate, it saves, but it also doesn't fire OnBeforeUpdate and OnBeforeInsert; none of the code is executed in either event.
I am following the steps outlined here:
Is there something I am missing? I suppose I can try on the same Account and Contact events but that means duplication of code when what I really want to do is check against the Address entity regardless of the object associated with it.
12-01-2012 09:21 AM
1. sounds like you're creating an Address entity in your external assembly, rather than getting a reference to it? Which is why all the fields are blank - it's just giving you the shell to fill.
2. the events should be on the address entity, not the account entity; only the address will fire the onBeforeInsert/onBeforeUpdate (the Account entity does not get updated, the Address has the AccountId in a M:1 relationship so the Account entity is unaware of the record change.)