Add new checkbox DDDIsParent unbound control on CustTable (form)
class DDDCustTableFormEventhandler
{
[FormControlEventHandler(formControlStr(CustTable, DDDIsParent), FormControlEventType::Modified)]
public static void DDDIsParent_OnModified(FormControl sender, FormControlEventArgs e)
{
FormCheckBoxControl process = sender as FormCheckBoxControl;
FormRun fr = process.formRun();
FormDataSource CustTable_ds = fr.dataSource('CustTable');
CustTable_ds.executeQuery();
}
}
[ExtensionOf(formDataSourceStr(CustTable,CustTable))]
final class DDDCustTableFormDS_Extension
{
void executeQuery()
{
FormCheckBoxControl myCheckBox = element.design().controlName(formControlStr(CustTable, DDDIsParent));
FormDataSource custTable_ds = this.formRun().dataSource('CustTable');
if (myCheckBox.checked())
{
DDDCustParentChild parentCustomer;
CustTable custTableLoc;
str custId;
container custList;
custList = conNull();
// get the all child customers of the parent
while select PARENTACCOUNT from parentCustomer group by PARENTACCOUNT
exists join custTableLoc
where custTableLoc.RecId == parentCustomer.ParentAccount
{
custList += CustTable::findRecId(parentCustomer.PARENTACCOUNT).AccountNum;
}
if(custList)
{
this.query().dataSourceTable(tableNum(CustTable)).clearRanges();
this.query().dataSourceTable(tablenum(CustTable)).clearDynalinks();
for (int i = 1; i <= conLen(custList); i++) // adding all child ranges to query
{
custId = conPeek(custList, i);
this.query().dataSourceName(custTable_ds.name()).addRange(fieldnum(CustTable, AccountNum)).value(queryValue(custId));
}
}
}
else
{
this.query().dataSourceTable(tableNum(CustTable)).clearRanges();
this.query().dataSourceTable(tablenum(CustTable)).clearDynalinks();
}
next executeQuery();
}
}
No comments:
Post a Comment