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, ...
Answered

action menu item not opening and giving error

(3) ShareShare
ReportReport
Posted on by 1,836
i have provide the action menu item to the controller class and the controller will be running for the service class but on the front end it showing me error , i am posting my code below can any one let me know where i am getting wrong
class ChequeDepositController extends SysOperationServiceController
{
    

    public ChequeDepositController()
    {
        super(classStr(ChequeDepositController),
              methodStr(ChequeDepositService, exportPDCToTxt),
              SysOperationExecutionMode::ScheduledBatch);
    }

    public static void main(Args _args)
    {
        ChequeDepositController controller = ChequeDepositController::construct();

        controller.parmDialogCaption("Export Customer Cheque Deposit");
        controller.parmShowDialog(true);
        controller.startOperation();
    }

    public static ChequeDepositController construct(SysOperationExecutionMode _executionMode = SysOperationExecutionMode::ScheduledBatch)
    {
        ChequeDepositController controller = new ChequeDepositController();
        controller.parmExecutionMode(_executionMode);
        return controller;
    }

    protected Object newDefaultContract()
    {
        return new ChequeDepositContract();
    }

}
 
Capture13.PNG
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    Let me post the error message as text: Unable to execute static method main when type parameter is not specified. It sounds like you forgot to specify the class name on your menu item.
     
    Moved from Integration, Dataverse, and general topics forum to Finance | Project Operations, Human Resources, AX, GP, SL forum.
  • Suggested answer
    udaY-ch Profile Picture
    5,133 on at
    Hi
     
    The new method doesn't look correct.
     
     
    Please try using the following code instead
     protected void new()
     {
         super(classStr(ChequeDepositService), methodStr(ChequeDepositService, exportPDCToTxt), SysOperationExecutionMode::ScheduledBatch);
     }
     
    Thanks
    Uday
     

    If you found this answer helpful, kindly mark it as verified so it can assist others facing similar issues.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    Also, you have a bug here:
     
    super(classStr(ChequeDepositController),
                  methodStr(ChequeDepositService, exportPDCToTxt),
    Your intention seems to be calling ChequeDepositService.exportPDCToTxt() method, but that's not what your code says. It will create an instance of ChequeDepositController class and try to call its exportPDCToTxt() (which will fail, if there is no such a method).
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi everyone , 
    thanks for reply , i have added the controller class to the action menu , still it is showing the error ,please suggest me on this , i have added the controller class to the menu item below is my code 
    class ChequeDepositController extends SysOperationServiceController
    {
       
        public static void main(Args _args)
        {
            DepositController controller = ChequeDepositController::construct();
    
            controller.parmDialogCaption("Export Cheque Deposits to File");
            controller.parmShowDialog(false); // No dialog needed since no contract/input
            //controller.parmBatchInfo(new BatchInfo()); // Enable batch support
            //controller.parmBatchInfo().parmBatchExecute(true);
            controller.parmArgs(_args);
            controller.startOperation();
        }
    
        public static ChequeDepositController construct(SysOperationExecutionMode _executionMode = SysOperationExecutionMode::Synchronous)
        {
           ChequeDepositController controller = new ChequeDepositController();
            controller.parmExecutionMode(_executionMode);
            return controller;
        }
    
        public void new()
        {
            super(classStr(ChequeDepositService),
                  methodStr(ChequeDepositService, exportPDCToTxt),
                  SysOperationExecutionMode::Synchronous);
        }
    
    }
    
     class ChequeDepositService
    {
    
        public void exportPDCToTxt()
        {
            ISLCustPDCRegister   pdcRegister;
            LedgerJournalTable   journalTable;
            LedgerJournalTrans   journalTrans;
    
            TextIo               file;
            FileIOPermission     permission;
            #File
    
            str                  filePath, fileName, cid, folderPath;
            int                  lineCounter = 0;
            AmountCur            totalAmount = 0;
            Container            lines;
            str                  dataLine, headerLine;
            UtcDateTime          now = DateTimeUtil::getSystemDateTime();
            TimeOfDay            currentTime = DateTimeUtil::time(now);
            str                  timestamp;
            Date                 sessionDate;
            AmountCur            amount;
           
    
            // Hardcoded or fixed path on AOS (not user machine!)
            folderPath = @"C:\Users\Desktop\d365.txt"; // Must exist and be writable by AOS service account
    
            CompanyInfo companyInfo = CompanyInfo::find();
            cid = companyInfo.ARCIDNo;
          
    
           //timestamp = strFmt('%1%2%3%4%5%6',
           //            strRFix(int2Str(dayOfMth(DateTimeUtil::date(now))), 2, '0'),
           //            strRFix(int2Str(mthOfYr(DateTimeUtil::date(now))), 2, '0'),
           //           strRFix(int2Str(year(DateTimeUtil::date(now))), 4, '0'),
           //           strRFix(int2Str(currentTime.hour), 2, '0'),
           //           strRFix(int2Str(currentTime.minute), 2, '0'),
           //           strRFix(int2Str(currentTime.second), 2, '0'));
    
            timestamp = strFmt('%1%2%3%4%5%6',
                strRFix(int2Str(dateDay(DateTimeUtil::date(now))), 2, '0'),
                strRFix(int2Str(dateMonth(DateTimeUtil::date(now))), 2, '0'),
                strRFix(int2Str(dateYear(DateTimeUtil::date(now))), 4, '0'),
                strRFix(int2Str(timeHour(DateTimeUtil::time(now))), 2, '0'),
                strRFix(int2Str(timeMinute(DateTimeUtil::time(now))), 2, '0'),
                strRFix(int2Str(timeSecond(DateTimeUtil::time(now))), 2, '0'));
    
    
            fileName = strFmt("CCSS_%1_%2.txt", cid, timestamp);
            filePath = folderPath + "\\" + fileName;
    
            permission = new FileIOPermission(filePath, #io_write);
            permission.assert();
    
            file = new TextIo(filePath, #io_write);
            if (!file)
            {
                throw error("Unable to open file for writing.");
            }
    
            file.outFieldDelimiter(',');
    
            sessionDate = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
    
            while select ChqName_front,
                         ChqName_back,
                         CheckNumber,
                         MICRNumber,
                         MaturityDate,
                         PaymentReference
                from pdcRegister
                where pdcRegister.PDCStatus == ISLPDCStatus::Received
                   && pdcRegister.MaturityDate <= sessionDate
                join journalTable
                    where journalTable.JournalNum == pdcRegister.JournalNum
                join Txt from journalTrans
                    where journalTrans.RecId == pdcRegister.LedgerJournalTrans
            {
                amount = pdcRegister.displayAmount();
                lineCounter++;
                totalAmount += amount;
    
                dataLine = strFmt('%1,%2,%3,%4,%5,%6,%7,%8,%9',
                                  lineCounter,
                                  pdcRegister.ChqName_front,
                                  pdcRegister.ChqName_back,
                                  pdcRegister.CheckNumber,
                                  pdcRegister.MICRNumber,
                                  date2str(pdcRegister.MaturityDate, 123, 2, 1, 2, 1, 4),
                                  amount,
                                  pdcRegister.PaymentReference,
                                  journalTrans.Txt);
    
                lines += dataLine;
            }
    
            file.write("S.No", "CHQNAME_FRONT", "CHQNAME_BACK", "CHECKNUMBER", "MICRNUMBER", "MATURITYDATE", "Amount", "PaymentReference", "Txt");
    
            for (int i = 1; i <= conLen(lines); i++)
            {
                file.write(conPeek(lines, i));
            }
    
            file.write("");
            headerLine = strFmt("Total Records: %1, Total Amount: %2", lineCounter, totalAmount);
            file.write(headerLine);
    
            CodeAccessPermission::revertAssert();
    
            info(strFmt("Export completed. %1 record(s) written to: %2", lineCounter, filePath));
        }
    
    }
     
  • Dineshkarlekar Profile Picture
    1,836 on at
    i am getting this error when setting the menu item as start up object and checking , can you please help me on this.
    System.InvalidOperationException: "Could not resolve X++ type class 'ChequeDepositController' to a managed type."
       at Microsoft.Dynamics.Ax.Xpp.DictClass.getXppType()
       at Microsoft.Dynamics.Ax.Xpp.DictClass.Callstatic(String _methodName, Object[] varArgs)
       at Dynamics.AX.Application.SysClassRunnerHelper.`runMainMethod(SysClassRunnerState state) in xppSource://Source/ApplicationFoundation\AxClass_SysClassRunnerHelper.xpp:line 30
       at Dynamics.AX.Application.SysClassRunnerHelper.runMainMethod(SysClassRunnerState state)
       at Dynamics.AX.Application.Forms.SysClassRunner.FormControl.timerControl.elapsed() in xppSource://Source/ApplicationFoundation\AxForm_SysClassRunner.xpp:line 52
    
     
  • Suggested answer
    udaY-ch Profile Picture
    5,133 on at
    Hi
     
    Your service class should extend the base class - SysOperationServiceBase
     
    Thanks
    Uday
     

    If you found this answer helpful, kindly mark it as verified so it can assist others facing similar issues.

  • Dineshkarlekar Profile Picture
    1,836 on at
    thanks for reply ,
    @udaY-ch   but i am not using the runbasebatch , i am using the sysoperation framework  is it right to use the SysOperationServiceBase , please guide me on this .
     
     
    thanks,
    Regards, 
     
    Dinesh 
  • Suggested answer
    udaY-ch Profile Picture
    5,133 on at
    Hi
     
    The SysOperation framework is mainly used for batch processing and works differently from the older RunBaseBatch framework. But even if you don't need to run a batch job and just want to show a dialog to perform some actions, you can still use the SysOperation framework.
     
    If you want to use the SysOperation framework, your service class must extend the SysOperationServiceBase class. But if you're not planning to use this framework, then there's no need to extend your classes with SysOperationServiceBase or SysOperationServiceController
     
    Take a look at the post for understanding and its objects,
     
    Thanks
    Uday
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    No, it's not true. The service class doesn't have to extend SysOperationServiceBase; it's optional.
     
     : The error is weird. Try recompiling the module before trying it again.
  • Dineshkarlekar Profile Picture
    1,836 on at
    yes you are right @Martin Dráb what ever changes i am making are not reflecting on the front end , it is module related issue , mean while i am getting the error related to converting dates into the string 
    Error    The name 'dateDay' does not denote a predefined function,  a static method on the Global class nor a previously defined local function. 
    i am getting error on every line can you , will update you once the module is build fully .
      timestamp = strFmt('%1%2%3%4%5%6',
                strRFix(int2Str(dateDay(DateTimeUtil::date(now))), 2, '0'),
                strRFix(int2Str(dateMonth(DateTimeUtil::date(now))), 2, '0'),
                strRFix(int2Str(dateYear(DateTimeUtil::date(now))), 4, '0'),
                strRFix(int2Str(timeHour(DateTimeUtil::time(now))), 2, '0'),
                strRFix(int2Str(timeMinute(DateTimeUtil::time(now))), 2, '0'),
                strRFix(int2Str(timeSecond(DateTimeUtil::time(now))), 2, '0'));
     

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 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans