Validation and null values

Is there a way to check if mandatory fields are null and give the user a specific error message.

The validation on the column info tab of the dataprovider does not work
for checking null values.

Servoy itself gives a user unfriendly message :
Invalid input, validation failed for ‘’ , with null value

I would like to trap this error myself and give the user a friendly message.

You can do that by using Servoy Exception.
by checking the error : ServoyException.INVALID_INPUT

write your logic in a global method to handel the error and attach it to the on error method under solution settings.

Hope it helps.

Thanks Ars,

This works when you save the data to the database,
but i want to check the fields in the form without
saving data tot the database.

I don’t really follow…

You say the column level validation does not work, but also that you do not want to check on column level…

What exactly do you want at what moment?

The message “Invalid input, validation failed for ‘’ , with null value”: When do you see that?

Paul

What i want to do is : check required fields for null values without (or before) saving the data to the database.

In a pre-save method.

I get the message when autosave is off and i am in a record and make a numeric field empty. (without saving)
It does not happen with a required text filed.

I have tested a column validation in the dataprovider, but i can not
test for null values there.

i am preparing a case

Created a case.
Found the problem :

For a required numeric field, the validation method (dataprovider) is not executed when the field is empty/null. It is executed for any other value.
This seems to be a bug.

For required text fields the validation method is always executed, even
if the field is empty/null. As it should.

Validation global method to check null value on field text2 example :

if (arguments[0])
{
  application.output('text2 oke');
  return true;
}
else
{
  application.output('text2 null');
  return false
}

I have same kind of situation. I also have the message

The message “Invalid input, validation failed for %%input%% , with null value”

I have an errorhandler and it is activated in my solution settings.
When I make a not null value empty, I see the errorhandler is triggered.

In my errorhandler I can even find the form that triggered the error using the application.getMethodTriggerFormName()

But I also would like to have the element that triggered the error. I expected that application.getMethodTriggerElementName() would have given the name of the element, but unfortunately that is not the case.

Is that a bug? Or is there another way to obtain the field that triggered the errorhandler.

And why do I see %%input%% in my message? Is it there to replace it myself by an own text? If so, it would be great if I have the field that triggered the problem.

Another problem is that when I make a field (null not allowed) on an existing record empty, that I want to continue filling my form until I save that data to the database. Is there anyway that I can unset/skip the NULL check while I’m editing my record (AutoSave=Off)? Now the cursor remains on that field and I can’t go to any other field on my form.

Hi All

My error seem to be related to what is already described in this thread so I post it here.

We went into production with our application and users found that when removing a number in an integer field, we Servoy throws this error message!
The database field (Postgres) is integer, null allowed. So it must be possible to enter no value, i. e. remove an existing value in the field.

My questions are:

  • Where does this message come from?
  • What error handler is triggered here?
  • The number in the field get’s read and I can’t leave the field?
  • The app is locked and the user doesn’t know what to do… (I also don’t know)?

It obviously looks like a bug, but such a trivial bug???

How were the problems solved in this thread?

Regards, Robert