Announcements
Hi,
I want to prevent user from switching to other record in grid, similar to 'ProdRoute' Form. If you create a new record via new button on that forms action pane, a new column is created in the grid. however if you dont fill all mandatory fields and try to select another record, a warning is shown and the selection doesn't change until you give all information. can you give me an idea on how to do that? i tried with overwritign leaverecord, validatewrite and active method with no success.
best regards
Can you please share some screenshots to illustrate that?
1) A screenshot of validateWrite method of the CustGroup data source
2) Screenshot of CustGroup form where you have started creating a new record
3) Screenshot of CustGroup form where you succesfully selected another record after trying to create a new one
Anyway, if that's the case, then the problem is in your system, and not in your code. In which case it's not useful to focus on the code anymore. But I suspect that you are somehow missing some detail, that's the most likely explanation. But not the only one :)
I can select another record...
There must be something wrong but we don't yet see it in the details that you shared.
Just to illustrate a simple example that you can examine, let's use a simple form, CustGroup.
Go to the CustGroup data source, override validateWrite method so that it always returns false.
Now, try to create a new record in the form, and see if you can select another record in the grid. I can't.
Yes.
The grid itself has a property called DataSource. Is it ProdRoute?
Right. Sorry I am new to AX, how do I know if it's the Primary data source?
Ok so if you click ctrl+s it's called ,but not when you click another record in the grid?
Is ProdRoute the primary data source of your grid?
Good idea, however nothing is printed.
Edit: It is getting called, when I try to save by pressing ctrl+s
If your breakpoint is not hit, it could also just mean that the debugger didn't kick in. But the code might still be executed. I think that the debugger doesn't really kick in when debugging methods in form sub-elements (data sources, controls...).
Just to be sure, could you add an infolog in your validateWrite, to print the return value to infolog?
public boolean validateWrite() { boolean ret = super() && this.isValid(); info(strFmt("%1", ret)); return ret; }
I've set a breakpoint at method head? Thanks for your advice, i've had it like that beforehand
André Arnaud de Cal...
294,217
Super User 2025 Season 1
Martin Dráb
232,978
Most Valuable Professional
nmaenpaa
101,158
Moderator