Monday, 18 April 2022

Jumpref method in d365 F&O

 /// <summary>

/// AccountingSourceExplorer form  extension

/// </summary>

[Extensionof(formStr(AccountingSourceExplorer))]

final class XXXAccountingSourceExplorerForm_Extension

{

    /// <summary>

    /// This method is used to navigate the invoice forms

    /// </summary>

    /// <param name = "_formControl">FormControl</param>

    public void jumpRefInvoiceId(FormControl _formControl)

    {

        AccountingSourceExplorerTmp  accountingSourceExplorerTmp;

        VendInvoiceJour              vendInvoiceJour;

        CustInvoiceJour              custInvoiceJour;

        MenuFunction                 menuFunction;

        Args                         args = new Args();

        FormDataSource               fds  = _formControl.formRun().dataSource(formDataSourceStr(AccountingSourceExplorer, AccountingSourceExplorerTmp));

        accountingSourceExplorerTmp  = fds.cursor();


        if (_formControl)

        {

            vendInvoiceJour.clear();

            select firstonly vendInvoiceJour

                where vendInvoiceJour.InvoiceId == accountingSourceExplorerTmp.XXXInvoiceId

                    && vendInvoiceJour.LedgerVoucher == accountingSourceExplorerTmp.SubledgerVoucher;

            if (vendInvoiceJour.RecId)

            {

                args.record(vendInvoiceJour);

                args.lookupRecord(vendInvoiceJour);

                menuFunction = new MenuFunction(menuitemDisplayStr(VendInvoiceJournal), MenuItemType::Display);

                menuFunction.run(args);

            }

            else 

            {

                custInvoiceJour.clear();

                select firstonly custInvoiceJour

                    where custInvoiceJour.InvoiceId == accountingSourceExplorerTmp.XXXInvoiceId

                    && custInvoiceJour.LedgerVoucher == accountingSourceExplorerTmp.SubledgerVoucher;

                if (custInvoiceJour.RecId)

                {

                    args.record(custInvoiceJour);

                    args.lookupRecord(custInvoiceJour);

                    menuFunction = new MenuFunction(menuitemDisplayStr(CustInvoiceJournal), MenuItemType::Display);

                    menuFunction.run(args);

                }

            }

        }

    }


}

-------------------------------------

/// <summary>

/// extension class for AccountingSourceExplorer form

/// </summary>

class XXXAccountingSourceExplorerFormEventHandler

{

    /// <summary>

    /// This method is OnPostRun of the form events

    /// </summary>

    /// <param name="sender">xFormRun</param>

    /// <param name="e">FormEventArgs</param>

    [FormEventHandler(formStr(AccountingSourceExplorer), FormEventType::PostRun),

        SuppressBPWarning('BPParameterNotUsed', 'False positive')]

    public static void AccountingSourceExplorer_OnPostRun(xFormRun sender, FormEventArgs e)

    {

        FormStringControl formCtrl = sender.design().controlName(formControlStr(AccountingSourceExplorer, AccountingSourceExplorerTmp_XXXInvoiceId));

        formCtrl.registerOverrideMethod(methodStr(FormStringControl, jumpRef), methodStr(XXXAccountingSourceExplorerForm_Extension, jumpRefInvoiceId), sender);

    }


}

No comments:

Post a Comment

DefaultDimension in d365 FO X++

 Navigate to PurchTable methods you can find with DefaultDimension this.DefaultDimension = this.mergeDimension(this.getDefaultDimension(),th...