bad Value


I have a DateEdit control in form.

How can I protect that control??

It mean that DateEdit set a range. my whole range is 2013-01-01 to 2013-12-31. I edit the first value. The user can put in the control eq 2013-06-01 and the range is set. my question is How can I protect the control that the user can’t put eq 2014-01-12.

Any Ideas??


you can try the following code : YourRange.status(RangeStatus::locked);

hope it helps




The user put in the form control a value and in the grid see the colums from the dataSource with the add range.

I want to protect the DateEDit for writing the bad value. eq. You have the form you write a date to the control, and when is incorrect he can’t put it.

Here’s a sample code that might help you:

public void executeQuery()
int i = 1,j;
j = this.queryRun().query().dataSourceNo(1).rangeCount();
while (i <= j)
i ++;

each time you input a range, it displays the range value, then you can test it



Ok, maybe this can help what I want to do.

I have a form with two design controls dateEdit: DateEdit:Start,DateEdit:Stop.

On the start of my form i set DateEdit:Start on 2013-01-01 and Date Edit:Stop on 2013-12-31.

Now when I change DateEdit:Start to 2013-01-10 the form will go foward, but when I change DateEdit:Start to 2014-01-01 DateEdit:Start clean the stops and wait when I chenge DateEdit:Start to correct value. thats all I want to do.

Now when I change DateEdit:Start to 2013-01-10 the form will go foward, but when I change DateEdit:Start to 2014-01-01 DateEdit:Start clean the DateEdit:Start stop the form and wait when I change DateEdit:Start to correct value. thats all I want to do.

What “form will go foward” and “stop the form” means? Do you want to prevent the form from closing if your validation fails?

Hi Martin, thx for the replay

In my form look like this:

Those two DateEdit’s set a range to the grid.

And I came up with that when the Validation is faild my form wait for the user when he put good Date’s (thats stop the form),

and when the validation is true the range is set in the grid. It is possible to write in DAX??

eq in C++ I have something like this

int value;




and in the Console Aplication when i wrote “bckhdsw” program clean the line ang wait for the next value, when i wrote “2233” the program go foward :slight_smile:

Command line and graphic user interface and obviously two different things with different rules. You can’t just “stop a form” - you can close it, ignore user input and so on. Most importantly, you can allow or disallow a form action (e.g. grid refresh) depending on some decision logic.

Don’t look for parallels with single-threaded console applications, it won’t help you to design a GUI. Think about actions asynchronously executed by users.

Ok. thx for the reply, I accepts solution. So How can I disallow a grid refresh??. I have wrote the validation for the DateEdit control’s,

the validation send me true or false, so now I need to now how to disallow refreshing grid or when the validation is false I want to

cleaning grid and disable user to e.g. ad a new record to grid

How do you execute the refresh? That’s what you’ll want to run conditionally.

In each DateEdit I have modified method where I have e.g purchTable_ds.executeQuery. The validation method I have in the form method’s.

Fine, you want to run executeQuery() only if your validation method returns true. Is it any problem for you?

Yes. if true I want executeQuery() to run if false I want to disallow refresing grid, No it isnt a proble, but the problem is that the user can mark records on grid, can add a new record, can explor to excel, I want protect the grid from the user when the validation is false, because e.g he put bed value to dateEdit, the grid isn’t refresh, but the user think’s it’s refresh. You know what I mean.

You can disable some user controls or remove all lines from the grid.

Yes Martin, I want do this but I don’t know how.

How can I remove all line??, How can I disable controls??,

Please write me some methods that do this, I read about it and put them to my code.

Form controls are objects and have method that you can call (one of them is enable()). Set AutoDeclaration property of the control you want to refer to by name in X++ code.

Probably the easiest way to remove records from a data source is disabling it: purchTable_ds.queryBuildDataSource().enabled(false). Don’t forget to enable it again when the validation passes.

I need to use the method in the control’s. e.g. until I write a corect value i can’t leave the control. How can i do it??

You can override its validate() method.

You should learn this basics before trying to write your own code. Look at Methods on Form Controls, for example. You should also realize that you’ve got a lot of standard X++ code to learn from.