Skip to main content

Notifications

Announcements

No record found.

Finance forum
Suggested answer

dialog class

Posted on by 216
Hi,

I want a dialog that has three radio buttons
  • option1
  • option2
  • option3 and if we tick option 3 next to it (to the right) a text control should appear
how to do option3 with a str control next to it?

The dialog shouldn't be a form, just using the dialog class
  • Anton Venter Profile Picture
    Anton Venter 9,343 Super User on at
    dialog class
    1. You want to separate your logic from the user interface.  This makes the code more reusable and the code can be used without being forced to load the form. E.g. batch processes are ujnable interact with the user interface.
    2. Short answer, enums are the way to go. There are other ways but then you will have to get creative.
    3. I did a quick test and realised that this is tricky because of the vertical alignment of the controls.
  • CU04051814-0 Profile Picture
    CU04051814-0 216 on at
    dialog class
    Hi Anton,

    1. Why would i need this code? i can simply link my menu item to a form?
     
    2. Again, if i use form with dialog pattern, then to show radio buttons, i'm forced to use enum to show the dialog, is there another way?
     
    3. if i use enums, how i'm going to make the txt field next to the last radio button and not below it?

     
  • Suggested answer
    Anton Venter Profile Picture
    Anton Venter 9,343 Super User on at
    dialog class
    You have to create the form during 'runtime' using the classfactory like in the prompt method below. The code below is an example of using your own form as a dialog and may need some adjustments besides changing the form name to your own form name and adding logic to the run method. I have not tested the code example below yet but I have used this pattern many before for small simple operations.
     
    You need an enum for the values but you can change the way it's displayed on the form.

    Add a form group control to the form and then add the two controls to the form group control.
     
    public final class MyCustomRunnableClassWithCustomFormAsDialog
    {	
    	private FormRun mFormRun;
    
    	public void run()
    	{
    		// Add logic here.
    	}
    
    	public boolean prompt()
    	{
    		Object obj;
    
    		mFormRun = classFactory.formRunClass(new Args(formStr(MyCustomFormDialog))); // Change form name.
    		mFormRun.init();
    		mFormRun.run();
    		mFormRun.wait();
    
    		if (mFormRun.closedOk()) // Did the user click OK?
    		{
    			obj = mFormRun;
    			// Retrieve form values set class variable here.
    		}
    
    		return mFormRun.closedOk();
    	}
    
    	public static void main(Args _args)
    	{
    		MyCustomRunnableClassWithCustomFormAsDialog operation = new MyCustomRunnableClassWithCustomFormAsDialog();
    
    		if (operation.prompt())
    		{
    			operation.run();
    		}
    	}	
    }
     
  • CU04051814-0 Profile Picture
    CU04051814-0 216 on at
    dialog class
    Hi Anton,

    What do you mean during runtime?

    I created a form with dialog pattern, it seems i can't use radio buttons unless i create an enum? can i do it without enums?
    and i wasn't able to put the name field next to the third button, only below it. how to do that?
  • Suggested answer
    Anton Venter Profile Picture
    Anton Venter 9,343 Super User on at
    dialog class
    Correct, you could just use your form as a dialog. I've done this before and it also works. You have to create your form during runtime though,
  • CU04051814-0 Profile Picture
    CU04051814-0 216 on at
    dialog class
    Hi Anton,

    if i will override templateForm() then this will mean i will need to create a new dialog form? So if i'm going to create a dialog form anyways, then In this case i can create a new dialog form and link it to my button without using sysoperation. Am i right or am i missing sth? and i think I can hide or disable fields in the dialog form itself without the need for UI builder class
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 3,706 on at
    dialog class
    Hi,
     
    You can use Sys Operation framework to implement your requirements, check the following link, it maybe helps you:
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Anton Venter Profile Picture
    Anton Venter 9,343 Super User on at
    dialog class
    Hello,
     
    With the SysOperation framework, you can create a custom dialog (with the text field to the right of the option control) and specify to use your custom dialog by overriding the SysOperationController.templateForm() override method.
     
     
  • CU04051814-0 Profile Picture
    CU04051814-0 216 on at
    dialog class
    Hi,

    I would like to do it with dialog class. But I want name field to be next to option3 and it can only be editable if option3 is clicked.​​​​​​​ And those radio controls are not enum
            Dialog                dialog;
            FormRadioControl      formRadioControl;
            FormBuildRadioControl formBuildRadioControl;
            FormBuildGroupControl formBuildGroupControl;
            int                   formBuildRadioControlId;
            DialogField           txt;
            //Build dialog with radio buttons
            dialog = new Dialog("Test Dialog");
            formBuildGroupControl = dialog.mainFormGroup();
            formBuildRadioControl = formBuildGroupControl.addControl(FormControlType::RadioButton,'radio buttons');
            formBuildRadioControlId = formBuildRadioControl.id();
            //set number of buttons
            formBuildRadioControl.items(3);
            //add descriptions
            formBuildRadioControl.item(1);
            formBuildRadioControl.text(" Radiobutton 1");
            formBuildRadioControl.item(2);
            formBuildRadioControl.text(" Radiobutton 2");
            formBuildRadioControl.item(3);
            formBuildRadioControl.text(" Radiobutton 3");
            txt = dialog.addField(extendedTypeStr(Name));



    And if i will do it with UIbuilder, then how?
     
  • Anton Venter Profile Picture
    Anton Venter 9,343 Super User on at
    dialog class
    Hello,
     
    I recommend using the SysOperation framework and a UIBuilder class. With your own UIBuilder class, you can show and hide the text field when a certain value in another field (option / enum) is selected. Have a look at some SysOperation framework examples and also some examples with a UIBuilder class (extending from SysOperationAutomaticUIBuilder).

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans