Hi guys,
I have a RunBaseBatch class which mainly will be running on batch. But this class will also available on a form for manual run.
As far as I know, to "identify" whether this class is called by a form or not, I need to have this statement :
if (callerForm.name() == formstr(MyForm)) { ..... }
Question is how to reach the form control as well ? because after this class is ran completely (when it is called from the FORM), I will need to direct the TabPage of MyForm. So in that form I have two TabPage : Detail and Overview Grid, just like SalesTable form when we open first time will be the grid list and we can click SalesId then it will switch to Detail TabPage. So I want to direct the form to always viewing the TabPage that contain/display the GridList right after my RunBaseBatch completed.
Thanks
It works.
This is what I needed. Thanks so much, Mohit.
Args is not required here.
Please try below code in the Clicked method
FormRunViewOptionHelper viewOptionHelper = element.viewOptionHelper(); viewOptionHelper.setViewOption(FormViewOption::Grid);
Hi Mohit,
Yes, that is what I'm trying to say, since it is a custom form.
Anyway actually I also tried the element like this :
But it doesn't switch to Grid.
Anything wrong with the statement ?
Thanks,
For Custom form, Extensions (Event Handler or CoC) is not required. You can override Clicked method of button and add your code in the form itself.
To access FormRun in clicked method use keyword 'element'.
Hi Mohit,
Works for event handler, but since this is a custom form anyway, may I know if we don't want to use Event Handler class ? I mean I tried to make less new classes. So I think from the clicked button is more like for my approach. But I'm still don't know how to set the ViewOption from the FormRun of myform.
Thanks,
You check this thread
community.dynamics.com/.../919018
But I think easy solution for you will be creating Event Handler for Clicked method and changing the view as specified in the article.
https://dynamicsaxknowledge.wordpress.com/2021/04/17/set-form-view-option-dynamically/
Let us know which one you tried and worked.
Hi Mohit,
That actually good idea. It is called from MenuItem button. I guess I'm overthinking of this.
However may I know how to direct it from the click button then ?
Thanks,
Hi, You must be calling this RunBaseBatch class either via MenuItem or calling menu item on click of a button. Instead of accessing form control in class, how about writing your code in Clicked method of that button.
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156