Hi,
Caller form datasource access in child form - Dynamics 365 for operations
[PostHandlerFor(formStr(VendBankAccounts), formMethodStr(VendBankAccounts, init))]public static voidVendBankAccounts_Post_init(XppPrePostArgs args){
FormRun element = args.getThis();
FormRun callerForm = element.args().caller();
FormDataSource formDataSource = element.ObjectSet();
PurchAgreementHeader purchAgreementHeader;
QueryBuildRange qbrVendor;
Query vendBankAccountsQuery = new Query();
if (callerForm && element.args().caller().name() == formStr(PurchAgreement)) {
vendBankAccountsQuery = formDataSource.query();
purchAgreementHeader = callerForm.dataSource(1).cursor() as PurchAgreementHeader;
qbrVendor = vendBankAccountsQuery.dataSourceNo(1).addRange(fieldNum (VendBankAccount, VendAccount)); qbrVendor.value(purchAgreementHeader.VendAccount);
formDataSource.query(vendBankAccountsQuery);
}
}
Sample code
[PostHandlerFor(formStr(SalesUpdateRemain), formMethodStr(SalesUpdateRemain, closeOk))]
public static void SalesUpdateRemain_Post_closeOk(XppPrePostArgs args)
{
FormRun element = args.getThis();
FormRun callerForm = element.args().caller();
FormDataSource formDataSource = element.ObjectSet();
SalesLine salesLine;
FormRealControl remainInventPhysical = element.design(0).controlName("RemainInventPhysical");
if (callerForm && element.args().caller().name() == formStr(SalesTable))
{
salesLine = callerForm.dataSource(2).cursor() as SalesLine;
//do your logic
}
}
[PostHandlerFor(formStr(SalesUpdateRemain), formMethodStr(SalesUpdateRemain, closeOk))]
public static void SalesUpdateRemain_Post_closeOk(XppPrePostArgs args)
{
FormRun element = args.getThis();
FormRun callerForm = element.args().caller();
FormDataSource formDataSource = element.ObjectSet();
SalesLine salesLine;
FormRealControl remainInventPhysical = element.design(0).controlName("RemainInventPhysical");
if (callerForm && element.args().caller().name() == formStr(SalesTable))
{
salesLine = callerForm.dataSource(2).cursor() as SalesLine;
//do your logic
}
}
Comments
Post a Comment