Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Validating Address Zip Codes from Account Details

[ Edited ]

I'm trying to implement a validation rule to check the format of zip codes based on the country chosen for an address. If its USA, use a certain regex, if its Canada, use another. 

 

So far I've implemented it on Account creation, and in my OnBeforeInsert event it fires and validates correctly.

 

From Account Details, though, I am having problems. Based on my work so far it looks like if you try to edit the Address from Account Details the Address OnCreate event is fired (even though its already been created, which I don't get - the validation does NOT fire from Address OnBeforeUpdate event). No Account change event seems to be fired either (again, not sure why the Account OnBeforeUpdate isn't fired here either).

 

And while that's OK, the ValidationException I am trying to throw is not displaying a pop up on the page - instead, the Address content that's already in the text area prior to validation is overwritten and replaced with the raw HTML for the generic SLX Exception page. And in that raw HTML, I see the custom Exception text that I want popped up to the user.

 

I can't imagine I'm the only person who has tried to do this with Address zip codes, so can someone suggest what the right way to do this is? 

 

 

Silver Contributor
Posts: 835
Registered: ‎03-24-2009

Re: Validating Address Zip Codes from Account Details

Aren't you doing this on the Address form itself? What does this have to do with the Account form? And shouldn't you check Contacts\Leads as well?

RJ Samp
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Re: Validating Address Zip Codes from Account Details

[ Edited ]

In our implementation, here's what's happening.

 

The Account Details form has an Address control that pops up when you edit the existing Address. 

 

When edited, the form appears to trigger the Address' OnCreate event. I've been able to verify this with relative certainty. It does not trigger any events for the Account, even after I click the Save icon on Account details (I'm prompted to update the Contact data also, which is fine). 

 

So in response to your question - What dos this have to do with the Account form? - the answer is I dont know and I am not sure why they are related. It is not the behavior I expected. What I thought would happen is the Account's OnBeforeUpdate event would fire, but it only does if I actually edit Account details content (presumably because the control has Account as its BindingSource). And when the Account's event fires, I *do* get a Validation Exception displayed correctly (as a modal dialog).

 

The source isn't the problem - it's how the exception details are being displayed. For whatever reason, the Validation Exception is being delivered in raw HTML if I try to trap this event.