web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to create dialog group to add menu item without contract class

(0) ShareShare
ReportReport
Posted on by 465

i created a dialog using sysOperationFramework that has 2 menu items in it.

I had to create a contract class just to make groups in order for the menu items to appear at the top of the dialog

[DataContractAttribute,
SysOperationContractProcessingAttribute(classStr(AAUIBuilder)),
SysOperationGroup('Grp1', 'Group1', '1'),
SysOperationGroup('Grp2', 'Group2', '2')]
class AAContract
{
}

class AAUIBuilder extends SysOperationAutomaticUIBuilder
{
    FormBuildFunctionButtonControl      button1;
    FormBuildFunctionButtonControl      button2;
    FormBuildGroupControl               grp1;
    FormBuildGroupControl               grp2;
    
    public void build()
    {
        super();

        grp1		= this.dialog().formBuildDesign().control('Grp1');

        button1 = grp1.addControl(FormControlType::MenuFunctionButton, 'Button1');
        button1.menuItemType(MenuItemType::Display);
        button1.menuItemName(menuItemDisplayStr(AAButton1));

        grp2		= this.dialog().formBuildDesign().control('Grp2');

        button2 = grp2.addControl(FormControlType::MenuFunctionButton, 'Button2');
        button2.menuItemType(MenuItemType::Display);
        button2.menuItemName(menuItemDisplayStr(AAButton2));
    }

}

since i'm not using the contract for anything, how can i create dialog groups without it?

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi D365FO user,

    Why don't you try creating a custom dialog form and use it instead of having a contract. You can check the form PurchEditLines as an example.

  • D365FO user Profile Picture
    465 on at

    Hi Gunjan,

    The dialig gets created automatically as i'm using sysOperationFramework (controller, service and contract classes) as i'm exporting an entity in the service class.

    There should be sth to say dialog.addgroup then assign menu item somehow  in the build method instead of doing the grouping in contract class

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Have you tried overriding the controller dialog method and add the dialog groups?

  • D365FO user Profile Picture
    465 on at

    Will i still need the UI builder for adding menu items or can i add it in the controller dialog method?

    Can you give me an example? 

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    I haven't tried this approach before, so I am not sure if this would work or not. UIBuilder is normally used with a contract class. If are trying to override the dialog method in the controller class, I believe you can add the dialog groups there itself.

    I would still suggest you go with a custom form instead of using a standard dialog. This will give you the freedom of designing the form as you need it. You can check this post for an example of how you can achieve this. You can also check the classes BudgetPlanAllocateController and HcmPositionForecastAddPositionController as well for examples.

  • Suggested answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    The right approach is implementing your own UI builder class.

    In more complex case, it would also be possible to design a form in AOT rather then building it at runtime. Then you would return the name of this form from templateForm() method of your controller class.

  • D365FO user Profile Picture
    465 on at

    Hi Gunjan,

    Thanks alot, i'll check ur suggestions

    Hi martin,

    I created my own UIbuilder that extends sysOperation... UIBuilder as seen in the question.

    So could i have created groups in UIbuilder build() method instead of of using contract class and adding menuItem buttons?  If yes can you please show me how?

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Sure. Don't call the logic of the parent class (super()) and add whatever you want (such as field groups) by yourself.

  • D365FO user Profile Picture
    465 on at

    Hi Martin,

    1. why should i exclude the super()?

    2. Also can you help me with the syntax, how can i add a formControlButton? as it's not working

    FormBuildFunctionButtonControl      button1;
    FormBuildGroupControl               grp1;
    dialogGroup = dialog.addGroup("group1");
    dialogGroup.Columns(0);
    button1 = grp1.addControl(FormControlType::MenuFunctionButton, 'Button1');

    3. I noticed that when i click the button and the form opens, then i close it. i don't get back to the dialog. it exits the whole dialog. How can i prevent that?

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    1. Because it calls the standard logic, which you don't want. Just try both options to see the diifference. You can also review the code, if you wish.

    2. Please give us a more detailed description of your problem. "It's not working" may mean anything.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans