Hello experts,
I am using Method Wrapper on CustTable form for CustTable datasource validateWrite method.
The only thing that I need is to read AccountNum field from the datasource
I found work around, it works, but I guess it is too complex and it should be a way to read table buffer in more elegant way.
Please see my class extension below:
[ExtensionOf(formdatasourcestr(CustTable, CustTable))]
final class AK_CustTableDataseource_Extension
{
public boolean validateWrite()
{
boolean ret;
AK_SOCompliance objAK_SOCompliance;
SalesTable objSalesTable;
CustTable objCustTable;
ret = next validateWrite();
if (ret)
{
//Here is the portion I don't like BEGIN
FormRun formRun=this.formRun();
Common cmn = formRun.dataSource(1).cursor();
if (cmn is CustTable)
{
objCustTable = cmn;
//if (CustTable.AccountNum == '')
if (objCustTable.AccountNum != '')
//Portion I don't like END
{
select firstOnly objAK_SOCompliance
join * from objSalesTable order by objSalesTable.CreatedDateTime desc
where
objAK_SOCompliance.SalesId==objSalesTable.SalesId
&& objSalesTable.CustAccount==objCustTable.AccountNum;
if (objAK_SOCompliance.SalesId)
{
info("Compliance record for recent Sales Doc: " +
objAK_SOCompliance.SalesId + ' ' + objAK_SOCompliance.Compliance);
}
else
{
info("No compliance record");
}
}
}
}
return ret;
}
}