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 :
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,284 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
    237,965 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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans