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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

The number of arguments specified for the function run is wrong?

(0) ShareShare
ReportReport
Posted on by 932

Hi,

I get error message in method main:

void run()
{
EmplId employee;
dialog d;
str dialogMess;
DialogField dialogFromDate;
DialogField dialogToDate;
DialogField dialogEmployee;
;
dialogMess = "Générer des lignes de saisie";


d = new dialog(dialogMess);
dialogFromDate = d.addFieldValue(typeid(TransDate),fromDate, "Date début: ");
dialogToDate = d.addFieldValue(typeid(TransDate),toDate,"Date fin: ");
dialogEmployee = d.addFieldValue(typeid(EmplId),employee,'Employé: ');

if(d.run())
{
fromDate = dialogFromDate.value();
toDate = dialogToDate.value();
employee = dialogEmployee.value();
if((mthOfYr(fromDate)<mthOfYr(systemdateget()))||( mthOfYr(fromDate)>mthOfYr(systemdateget()) && year(fromDate)<year (systemdateget())))
throw error("Le mois de référence doit obligatoirement être postérieur ou égal au mois courant!");
//if the variable employee is not empty
if(employee!="")
{
select emplTable where emplTable.EmplId==employee;
this.CalculRTT_CP(emplTable.CalendarId);
this.CreateProjTimeSheet_APS(emplTable.EmplId);
}

}

static void main(Args _args)
{

APS_GenerateAutomaticRequestRTT aps_GenerateAutomaticRequestRTT = new APS_GenerateAutomaticRequestRTT();
;

aps_GenerateAutomaticRequestRTT.run(); // I get error in this line: The number of arguments specified for the function is wrong.

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi BASMA,

    Probably aps_GenerateAutomaticRequestRTT.run() method has parameters that you need to pass, you can easily find this out by checking method signature.

  • Verified answer
    Martin Dráb Profile Picture
    239,370 Most Valuable Professional on at

    Are you sure that the error is thrown when calling run() and not inside run()?

    By the way, let me format your code to make it easier to read. Next time, please use the </> button in the rich formatting view to paste source code.

    void run()
    {
        EmplId employee;
        
        str dialogMess = "Générer des lignes de saisie";
        Dialog d = new Dialog(dialogMess);
        DialogField dialogFromDate     = d.addFieldValue(typeId(TransDate), fromDate, "Date début: ");
        DialogField dialogToDate     = d.addFieldValue(typeId(TransDate), toDate, "Date fin: ");
        DialogField dialogEmployee     = d.addFieldValue(typeId(EmplId),      employee, "Employé: ");
        
        if (d.run())
        {
            fromDate = dialogFromDate.value();
            toDate = dialogToDate.value();
            employee = dialogEmployee.value();
            
            if (mthOfYr(fromDate) < mthOfYr(systemDateGet())
              || (mthOfYr(fromDate) > mthOfYr(systemDateGet()) && year(fromDate) < year(systemDateGet())))
            {
                throw error("Le mois de référence doit obligatoirement être postérieur ou égal au mois courant!");
            }
            
            if (employee != "")
            {
                select emplTable
                    where emplTable.EmplId == employee;
                    
                this.CalculRTT_CP(emplTable.CalendarId);
                this.CreateProjTimeSheet_APS(emplTable.EmplId);
            }
        }
    }
    
    static void main(Args _args)
    {
        APS_GenerateAutomaticRequestRTT aps_GenerateAutomaticRequestRTT = new APS_GenerateAutomaticRequestRTT();
        ;
        aps_GenerateAutomaticRequestRTT.run(); // I get error in this line: The number of arguments specified for the function is wrong.
    }

    By the way, if it's a RunBase class, trying to use a dialog inside run() is a bug. Use appropriate method such as dialog() and getFromDialog(), which are executed on client before calling run() on server.

  • BASMA Profile Picture
    932 on at

    Thanks Martin,

    When I use a dialog() and getFromDialog() I don't have error.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans