Hello All,
I need to calculate the Advance Payment Amount for the lines of the selected salesId.
I have created a Menu item button for the dialog box and added two parameters, one of which is salesId, and the other is Advance Payment.
SalesId needs to be auto-filled when the button is clicked, and the Advance Payment will be filled manually.
And also, I have created the Contract class and the service class.
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.
This is my code snippet:
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();
}
}
}