Hi! Sometimes Customer requires that developed solution doesn’t touch the standard forms, because Customer wants minimize the merge process. If you should add some controls to the form without form modification than this topic could help you.
Let’s assume that CustInvoiceJournal and CustConfirmJournal forms should have new menu button with menu item.
- Create the static method:
static void addMenuItems(formRun _caller)
{
FormFunctionButtonControl formFunctionButtonControl;
FormButtonGroupControl formButtonGroupControl;
FormMenuButtonControl formMenuButtonControl;
; switch (_caller.name())
{
case formstr(CustInvoiceJournal) :
formButtonGroupControl = _caller.form().design().control(identifierstr(OverviewButtonGroup));
break;
case formstr(CustConfirmJournal) :
formButtonGroupControl = _caller.form().design().control(identifierstr(ButtonGroupOverview));
break;
case formstr(CustPackingSlipJournal) :
formButtonGroupControl = _caller.form().design().control(identifierstr(OverviewButtonGroup));
break;
}
if (formButtonGroupControl)
{
// new menu button
formMenuButtonControl = formButtonGroupControl.addControl(FormControlType::MenuButton, identifierstr(NameOf_MenuButton));
formMenuButtonControl.text('New menu button');
//new menu item
formFunctionButtonControl = FormMenuButtonControl.addControl(FormControlType::MenuFunctionButton, identifierstr(NameOf_MenuItem));
formFunctionButtonControl.menuItemType(MenuItemType::Display);
formFunctionButtonControl.menuItemName(MenuItemDisplayStr(CustTable));
}
} - Add the following code to the SysSetupFormRun.init method:
public void init()
{
; Class1::addMenuItems(this);//New code
super();
SysSecurityFormSetup::loadSecurity(this);
this.dimensionFieldCtrls();
this.inventStorageDimFieldCtrls();
if (this.isWorkflowEnabled())
{
workflowControls = SysWorkflowFormControls::construct(this);
workflowControls.initControls();
}
}
This is all.
- Add the following code the the SysSetupFormRun.init method:
public void init()
{
;
super(); SysSecurityFormSetup::loadSecurity(this);
this.dimensionFieldCtrls();
this.inventStorageDimFieldCtrls();
if (this.isWorkflowEnabled())
{
workflowControls = SysWorkflowFormControls::construct(this);
workflowControls.initControls();
}
if (Class1::overload(this)) // new code
{ // new code
this.controlMethodOverload(true); // new code
this.controlMethodOverloadObject(new Class1(this)); // new code
}
} - The Class1 class has the following methods:
void new(FormRun _caller)
{
;
caller = _caller;
}
public static boolean overload(FormRun _caller)
{
;
switch (_caller.name())
{
case formstr(CustInvoiceJournal):
return true;
}return false;
}
To override method behavior the class method should have the following name: ControlName_methodName(). In our case we override the clicked() method of the SalesInvoiceShow control:
void SalesInvoiceShow_clicked()
{
CustInvoiceJour custInvoiceJour;
FormDataSource formDataSource;
FormButtonControl buttonControl;
;
formDataSource = caller.dataSource();
custInvoiceJour = caller.dataSource().cursor();
if (custInvoiceJour.InvoiceId != "11111111")
{
info("You can't open invoice preview because we override button behaviour");
}
else//call super()
{
buttonControl = caller.controlCallingMethod();
buttonControl.clicked();
}
}
That is all. If we open the CustInvoiceJournal and click the Preview/Print the info message will be shown. If Invoice id is 11111111 then button will have the standard behaviour (i.e. the Invoice will be shown)
Copied from Experts website....... Dynamicsaxtraining.
You can always reach me at axapta4all@gmail.com
Anonymous Axaptian
các món ăn giúp giảm cân
ReplyDeletecách chữa bệnh mất ngủ về đêm
công thức kem trộn trắng da toàn thân
uống collagen lúc nào là tốt nhất
đông trùng hạ thảo có tác dụng gì
cách trị sẹo lồi lâu năm
hướng dẫn tập yoga giảm cân một cách nhanh chóng và an toàn .