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.
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));
}
}
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();
}
}
Sometimes it is required to change form behavior without form modification. Let’s assume when User clicks the Preview/Print button on the CustInvoiceJournal form the info message shows.
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
}
}
void new(FormRun _caller)
{
;
caller = _caller;
}
public static boolean overload(FormRun _caller)
{
;
switch (_caller.name())
{
case formstr(CustInvoiceJournal):
return true;
}
return false;
}
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();
}
}
All the best 😉