最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

D365: How to get caller form name in Form extension class

网络文摘 William 1282浏览 0评论

Purpose:

Demonstrate how to get caller form name in a Form extension class in X++.

Application:

Dynamics 365 for Finance and Operations

Solution:

The code below gives a very good example of how can get the caller form name in a Form extension class in X++ which then can be used to run the business logic. In the code below, we’re adding a display method for a control on the form RetailAddItems to display Site. We’re getting Site from a form data source on the caller form. In this case, caller form is PurchTable and caller form data source is also PurchTable.

Code

[ExtensionOf(formStr(RetailAddItems))]
internal final class MAK_RetailAddItems_Extension
{
	display InventSiteId displayPurchSiteId()
    {
        InventSiteId siteId;
        FormRun callerFormRun;

        callerFormRun = this.args().caller();

        if (callerFormRun.name() == formStr(PurchTable))
        {
            FormDataSource purchTable_ds = callerFormRun.dataSource(formDataSourceStr(PurchTable, PurchTable)) as FormDataSource;
            PurchTable purchTable = purchTable_ds.cursor() as PurchTable;

            if (purchTable)
            {
                siteId = purchTable.InventSiteId;
            }
        }

        return siteId;
	}
}
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址