Dynamics 365 gives the capability to create dialog form.We can however also create a dialog form through code dynamically at runtime.
- Create a class called DEMODialog extending RunBase
- Add global variables that will be the parameters that will be accepted in our dialog
- Create dialog method to give the dialog caption, add the field, add field label. Look at the image at the last to understand the below code.
- Override the validate method to validate if a value is provided in the field(if needed)
- Create the main method to execute the dialog box.
- Create an action menu item with the object type as class and object as DEMODialog.
- Open the menu item to trigger the dialog.
public class DEMODialog extends RunBase
{
}
public class DEMODialog extends RunBase
{
DialogField dialogSalesId;
SalesId salesId;
FormDataSource formDataSource;
}
Object dialog()
{
Dialog dialog = super();
;
dialog.caption("Dialog caption");
dialog.addTabPage("Tab page");
DialogGroup dialogGroup = dialog.addGroup("dialog group");
// Add a field for a name to the dialog. This will populate the field with
// any value that happens to be saved in name from previous uses of the
// dialog.
dialogSalesId = dialog.addField(extendedTypeStr(SalesId));
dialogSalesId.label("Salesid");
return dialog;
}
boolean validate (Object _calledFrom = null)
{
boolean isValid;
isValid = super(_calledFrom);
// Perform any validation nessecary.
if (!dialogSalesId.value())
{
isValid = checkFailed("Validation failed")) && isValid;
}
return isValid;
}
public static void main (Args _args)
{
DEMODialog demoDialog= new DEMODialog();
// Display the dialog. This only returns true if the the user clicks "Ok" and validation passes.
if (demoDialog.prompt())
{
//Logic when Ok is clicked goes here
}
The final dialog that opens up :
Final Dialog |
Comments
Post a Comment