Previous Thread

8/15/2006 2:59:03 PM    Validate string control content
Hi All! 
 
How can I validate a string control content? The scenario is as follows: 
 
In the VendTable form there's a combobox control with the category of 
 
the vendor (company, person, none, foreigner). I need to check if the 
 
next field (named CNPJCPFNum in localized AX 3.0 SP5) is empty ONLY IF 
 
the category (the preceding field) is set to company or person. 
 
If it is empty/blank (if the user didn't input anything in the 
 
CNPJCPFNum control) I need to pop up a box::stop dialog. 
 
I tried to override the CNPJCPFNum control's leave method and put the 
 
following code in it (and breakpointed it) but when I TAB through to the 
 
next field nothing happens (no dialog and no debugger). 
 
Anyone? 
 
The code: 
 
--------8<---BEGIN----8<---------- 
 
public boolean leave() 
 
{ 
 
boolean ret; 
 
ret = super(); 
 
if (element.design().controlName('National1_CNPJCPFNum').valueStr() 
 
== '') { 
 
if ((vendTable.VendCategory == CustVendCategory_BR::Company) 
 
|| (vendTable.VendCategory == CustVendCategory_BR::Person)) { 
 
box::stop('@WKL51', '@SYS59975'); 
 
element.design().controlName('National1_CNPJCPFNum').setFocus(); 
 
} 
 
} 
 
return ret; 
 
} 
 
--------8<---END----8<----------



8/17/2006 1:48:40 PM    Re: Validate string control content
Hi Morten! 
 
Thanks for your reply. I did just what you suggested when now it's 
 
working as I needed! 
 
What I didn't understand is why the code in leave method of the form 
 
control doesn't get called when I tabbed through to the next field... 
 
Anyway, thank you! 
 
mortenm wrote: