Details to Grid view does not call close, how to add validation before switching?
Views (72)
Hello AX World,
Did you know that closing Details View and returning to Grid View does not call method close?
Why would I ask such a question? you may ask. Well, mostly because from user perspective it looks like a form was closed.
Let's say you have a requirement to prevent closing Details View before some condition is fulfilled (e.g. an attachment is added in the document handling).
How to implement such a requirement?
Restrictions:
What is happening behind the screen when it switches from Details View to Grid View and vice versa? It goes from one FormTabPage (hides it) to another FormTabPage (unhides it). Therefore, we can play with Tab control.
In this case, I am interested in one particular method tabChange, which supposed to validate tab changes.
To my knowledge, it is not possible to use Chain of Command (CoC), at least in the version 8.0 PU15.
Pre and Post event handlers are not available as, most probably, it is an abstract method.
The only option available is to register override method using method registerOverrideMethod on a Tab control.
Here is how it can be done:
Here you go. Once you implement the logic, you can prevent Details View from closing.
Please share if there is a better way to do this in the comments.
Be aware and take care!
* Original parameters does not always come first. Check out my blog post
Did you know that closing Details View and returning to Grid View does not call method close?
Why would I ask such a question? you may ask. Well, mostly because from user perspective it looks like a form was closed.
Let's say you have a requirement to prevent closing Details View before some condition is fulfilled (e.g. an attachment is added in the document handling).
How to implement such a requirement?
Restrictions:
- Methods close and canClose are not called.
- Method validateWrite is not suitable here as the required action is to be performed in the document handling form. If you try to implement it on validateWrite, you won't open the document handling, because it will try to write the record.
- Data source method leaveRecord is not called.
What is happening behind the screen when it switches from Details View to Grid View and vice versa? It goes from one FormTabPage (hides it) to another FormTabPage (unhides it). Therefore, we can play with Tab control.
In this case, I am interested in one particular method tabChange, which supposed to validate tab changes.
To my knowledge, it is not possible to use Chain of Command (CoC), at least in the version 8.0 PU15.
Pre and Post event handlers are not available as, most probably, it is an abstract method.
The only option available is to register override method using method registerOverrideMethod on a Tab control.
Here is how it can be done:
- Register an override in, for example, init method using CoC, if available.
- Create an override method. The first parameter must be the original parameter*. The second parameter must be FormTabControl.
void init()
{
next init();
Tab.registerOverrideMethod(methodStr(FormTabControl, tabChange),
methodStr(smmBusRelTableForm_Extension, tabChange),
this);
}
protected boolean tabChange(int _fromTab, FormTabControl _tabControl)
{
boolean ret = true;
//Your validation here
return ret;
}
Here you go. Once you implement the logic, you can prevent Details View from closing.
Please share if there is a better way to do this in the comments.
Be aware and take care!
* Original parameters does not always come first. Check out my blog post
This was originally posted here.

Like
Report
*This post is locked for comments