Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

'main' denotes a method, and cannot be reused in this context

(0) ShareShare
ReportReport
Posted on by 576

I am new in D365 development..

i am   learning from book named (cookbook) , there is topic about creating dialog using RunBase Class .

when applying this topic gave me an error 

main.png

I copied the class to another class but same error 

Here my code

class MyDialog extends RunBase
{        
    /// 
    /// Runs the class with the specified arguments.
    /// 
    /// The specified arguments.
    public static void main(Args _args)
    {        
        DialogField     fieldAccount,fieldName,fieldGroup,fieldCurrency,fieldPaymTermId,fieldPaymMode;
        CustName        CustName;
        CustGroupId     custGroupId;
        CurrencyCode    currencyCode;
        CustPaymTermId  PaymTermId;
        CustPaymMode    PaymMode;
    }

    public container pack()
    {
        return conNull();
    }

    public boolean unpack(container _packedClass)
    {
        return true;
    }

    Object dialog()
    {
        Dialog          dialog;
        DialogGroup     groupCustomer,groupPayment;
        DialogField     fieldAccount,fieldName,fieldGroup,fieldCurrency,fieldPaymTermId,fieldPaymMode;
        
        dialog = super();
        dialog.caption("Customer information");

        fieldAccount    = dialog.addField(extendedTypeStr(CustVendAC),"Customer informations");
        fieldName       = dialog.addField(extendedTypeStr(CustName),"Customer name");

        dialog.addTabPage("Details");

        groupCustomer   = dialog.addGroup("Setup");
        fieldGroup      = dialog.addField(extendedTypeStr(CustGroupId),"Customer group Id");
        fieldCurrency   = dialog.addField(extendedTypeStr(CurrencyCode),"Customer group Id");

        groupPayment        = dialog.addGroup("Payment");
        fieldPaymTermId     = dialog.addField(extendedTypeStr(CustPaymTermId));
        fieldPaymMode       = dialog.addField(extendedTypeStr(CustPaymMode));

        return dialog;
    }

    public static void main(Args _arge)
    {
        MyDialog myDialog = new MyDialog();
        if(mydialog.prompt())
        {
            myDialog.run();
        }
    }

}
 

My reference packages are : Application common - Application  Foundation - Application  Platform - Application  Suite - Calendar - Contact Person - Currency - Dimension - Directory - and Ledger .

Thank you in advance .   

  • Bala Chandra Profile Picture
    355 on at
    RE: 'main' denotes a method, and cannot be reused in this context

    Hi,

    Remove the first main method where only variables declared.

    There should be only one main method.

  • Ismail Mohamed Profile Picture
    576 on at
    RE: 'main' denotes a method, and cannot be reused in this context

    Sorry the error was there is 2 main methods

    sorry and thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 565

#2
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2025 Season 1

Product updates

Dynamics 365 release plans