web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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 .   

I have the same question (0)
  • Ismail Mohamed Profile Picture
    576 on at

    Sorry the error was there is 2 main methods

    sorry and thanks

  • Bala Chandra Profile Picture
    355 on at

    Hi,

    Remove the first main method where only variables declared.

    There should be only one main method.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 385 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 270

#3
Martin Dráb Profile Picture

Martin Dráb 243 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans