Click the button to redirect to a form with X++

Regarding customer requests to create a new button to redirect to another related form once the user presses on the button with X++, we can use the code below:



// The button is created on the custom form

[Control("Button")]

class RetailTransaction       

{

        /// <summary>

        /// RetailTransaction clicked

        /// </summary>

        public void clicked()

        {

            RetailTransactionTable retailTransactionTable;

            RetailTerminalId terminalId;

            POSIntegrationTerminalMapping terminalMapping ;

            Args args = new Args();

            ;

    

            // get mapping terminal id

            // TrackingRetailTransactionTable is DS

            

            terminalMapping = POSIntegrationTerminalMapping ::find(TrackingRetailTransactionTable.Store, TrackingRetailTransactionTable.Terminal);

            if(terminalMapping)

            {

                terminalId = terminalMapping.InternalTerminalId;

            }

            else

            {

                terminalId = TrackingRetailTransactionTable.Terminal;

            }

 

            select firstonly retailTransactionTable

                where retailTransactionTable.store == TrackingRetailTransactionTable.Store &&

                           retailTransactionTable.transactionId == TrackingRetailTransactionTable.TransactionNumber &&

                           retailTransactionTable.terminal == terminalId;

 

        args.record(retailTransactionTable);       

        args.parm(element.name());

        new MenuFunction(menuItemDisplayStr(RetailTransactionTable),

MenuItemType::Display).run(args);

    }

 }

Comments

Popular posts from this blog

How to customize electronic reporting in D365

Build HTML and send email in D365 FO with X++

Batch parallelism or multithreading in Dynamics 365 for Finance and Operations

How to Enable/Disable a Form Button with X++

How to create and run the Runbase batch class in D365

How to create and run the Runbase class in D365

Difference between InMemory and TempDB tables in D365 F&O

Customize the standard excel template in D365FO

How to create and run a batch class that extends RunBaseBatch in D365