Throw Error

Hi,

i have two fields in my form,i need to validate in such a way that i should not allow to get the record saved unless i enter values for either of the field…how to do?

Regards,

Rajee

In validatewrite method of the table

add the code:

if((field1 == ‘’ ) || (field 2 == “”))

throw error(“enter values”)

regards

Shon

But shon, i did the samething to another form …but i dint show me any error msgs

one clarification, do i need to use “ValidateWrie” in the table or the in the form datasource?

form also it shoul work, but i would also suggest you to override the table-validatewrite method

and write smthing like ret = checkfailed("no values ")

Regards

Shon

I agree with you shon,but i’m not getting it. my requirement is in the ‘AdressCountryRegion’ form, the record should’nt get saved unless i enter content in the ‘description’ field …can u please help

so raji - did u try by over riding table validate write method.??

if not

jus use this code

public boolean validateWrite()

{

boolean ret;

ret = super();

if(this.Name == ‘’)

ret = checkfailed(“no values”);

return ret;

}

trust me it wil work.,

regards

Shon

Shon, Correct me if i’m wrong

in the Form datasource ,i’ve written

public boolean validateWrite()
{
boolean ret;

ret = super();

if(AddressCountryRegion.description== " ")
{
box::info(“please enter values”);
}
return ret;
}

then as you have told,i overrid the validatewrite method in the AddressCountryRegion table also,but still i’m stuck up

Hi rajarajeshwari,

In Form AddessCountryRegion – DataSource – methods – overide the validatewrite method…

public boolean validateWrite()
{
boolean ret;

ret = super();
if(!AddressCountryRegion.Name)
{
ret = checkfailed(“Enter the %1”,AddressCountryRegion.Name);
}

return ret;
}

try this it may help you out…

Naresh Kolli

Thanks for the help Shon and Naresh

-Rajee