[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Raj

2/10/2006 3:04:00 AM

Hi ,
I need some help regarding the Field Validation. I have field Pool
warehouse Location in item attributes tab in invent table form. The Location
field should be mandatory only if the user selects a warehouse and also the
validation has to cheked to see whether the user has selected the correct
location which is linked to the warehouse.

what i need to know is where should the validation code be written , do any
one have code to do that.

thanks in advance
rr


1 Answer

Luegisdorf

2/10/2006 7:50:00 AM

0

Hi Raj

I suggest to create or modify the 'validateWrite(...)' method on the table
in data dictionary. After the super() call you make a condition to check if
your field should be mandatory and if it's still empty you just add add
warning and set the return value to false.

Would be look like this:

boolean validateWrite()
{
boolean ret;

ret = super();

if (myTable.FieldX == 'poolMustFieldIn' &&
! myTable.Pool)
{
// int this situation the pool field should be filled in!
ret = checkFailed("Ey you, please fill the field 'pool'");
}

return ret;
}

Of course you can use the 'validateWrite(...)' of the data source on the
form, but this way only in the specified form your conditional mandatory
field will checked.

If you want to show the field mandatory (with the red underlines), you have
to do following:

overwrite or modify the modified() method of the field which determs if your
Pool-Field is mandatory directly in the data source field on your form. After
super() call you can insert a line like this:

myTable_ds.object(fieldnum(MyTable, PoolField)).mandatory(myTable.FieldX ==
'PoolFieldMustFilledIn' );

in the active() method on the data source you have to add the same line
(after super() too).

There's only one restriction with the 'red lines': If the conditional field
is shown in a grid, every line takes effect with the red line (even only on
some records the PoolField is mandatory). But if your PoolField is not in a
grid, there should be no poblems.

Best regards
Patrick


"Raj" wrote:

> Hi ,
> I need some help regarding the Field Validation. I have field Pool
> warehouse Location in item attributes tab in invent table form. The Location
> field should be mandatory only if the user selects a warehouse and also the
> validation has to cheked to see whether the user has selected the correct
> location which is linked to the warehouse.
>
> what i need to know is where should the validation code be written , do any
> one have code to do that.
>
> thanks in advance
> rr
>
>