How to get calling menu name in extensions D365

We can write logic based on a current form called from which menu item.

Following is the code that helps you to achieve get the calling menu name.

    ///

    /// </summary>

    /// <param name="args"></param>

    [PostHandlerFor(formStr(CaseItemCreditLines), formMethodStr(CaseItemCreditLines, init))]

    public static void CaseItemCreditLines_Post_init(XppPrePostArgs args)

    {

        SalesLine  salesLine;

        FormRun    fromRun    =  args.getThis();

        if(fromRun.args().dataset() == tableNum(SalesLine)  && fromRun.args().menuItemName() == menuItemDisplayStr(CaseItemCreditLines))

        {

            salesLine = fromRun.args().record();

            fromRun.design(0).controlName(formControlStr(CaseItemCreditLines, sendMail)).visible(salesTable::isRelatedPO_IsVOR(salesTable::find(salesLine.SalesId)));

        }

 

    }


Comments

Popular posts from this blog

SSRS Report using Controller , Contract and RDP classes in D365

Exporting data to Excel through X++ code

COC for Form level method

How to pass the parameter from one form to another in Dynamic365

Multi Select Lookup in SSRS Report in D365