SalesId needs to be auto-filled when the button is clicked, and the Advance Payment will be filled manually.
I have also created the Contract and Service classes.
And then the calculated value will be stored in the Advance payment field in SalesLine.
The calculation part and the storing of the value are working fine, but the problem is with auto-filling the salesId and refreshing the parameter box each time it is opened.
public static void main(Args _args)
{
AdvPayController controller = new AdvPayController();
controller.parmClassName(classStr(AdvPayService));
controller.parmMethodName(methodStr(AdvPayService, process));
controller.parmArgs(_args);
controller.parmDialogCaption("Advance Payment");
controller.startOperation();
}
protected void initializeContract()
{
//super();
AdvPayContract contract = this.getDataContractObject();
// Always reset the dialog fields
contract.parmAdvancePay(0);
Args localArgs = this.parmArgs();
if (localArgs
&& localArgs.record()
&& localArgs.record().TableId == tableNum(SalesTable))
{
SalesTable salesTable = localArgs.record();
contract.parmSalesId(salesTable.SalesId);
}
}
protected void apply()
{
}
public void run()
{
super();
this.refreshSalesLines();
}
private void refreshSalesLines()
{
Args _argsLocal = this.parmArgs();
if (_argsLocal
&& _argsLocal.caller()
&& _argsLocal.caller() is FormRun)
{
FormRun formRun = _argsLocal.caller();
FormDataSource salesLineDss = formRun.dataSource(formDataSourceStr(SalesTable, SalesLine));
if (salesLineDss)
{
salesLineDss.research(true);
salesLineDss.refresh();
}
}
}