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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans