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,678
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();
    }

}
 
Categories:
  • Dineshkarlekar Profile Picture
    1,678 on at
    action menu item not opening and giving error
    hi Martin , 
    thanks for helping me out , my issue is resloved.
     
    Thanks,
    Regards,
     
     
     
    Dinesh
  • Verified answer
    Martin Dráb Profile Picture
    234,615 Most Valuable Professional on at
    action menu item not opening and giving error
    I already gave you a solution in my previous reply. We can simplify it even more, because you don't really need dealing with any binary data at all. Throw BinData away and simply use File::sendStringAsFileToUser(content) instead.
  • Dineshkarlekar Profile Picture
    1,678 on at
    action menu item not opening and giving error
       dataLine = strFmt('%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13\r\n',
                                      lineCounter,
                                      pdcRegister.ChqName_front,
                                      pdcRegister.ChqName_back,
                                      pdcRegister.CheckNumber,
                                      pdcRegister.MICRNumber,
                                      bankAccountTable.RegistrationNum,
                                      companyInfo.ARCIDNo,
                                      bankAccountTable.AccountNum,
                                      date2str(pdcRegister.MaturityDate, 123, 2, 1, 2, 1, 4),
                                      amount,
                                      pdcRegister.PaymentReference,
                                      Narration1,
                                      Narration2);
    
                    content += dataLine;
                }
    
                // Add summary line
                headerLine = strFmt("\r\nTotal Records: %1, Total Amount: %2\r\n", lineCounter, totalAmount);
                content += headerLine;
    
                // Write to file
                binData.setStrData(content);
                binData.saveFile(filePath);
    if i am not able to save the text file in aos can i create the test file by this part of code can you please suggest , i want to fix this once the txt file is generated i will work on the saving file part 
    please guide me on this 
  • Martin Dráb Profile Picture
    234,615 Most Valuable Professional on at
    action menu item not opening and giving error
    That's exactly what I was talking about. Trying to save the file on AOS is a bad desing that you can't use in the real solution and even using it during development can lead to problems like you current. The best solution is not doing it and using something like File::sendFileToUser() instead.
     
    Regarding the session date, which value on which line of code you're talking about? What did you find when you tried to debug your code before asking for help?
  • Dineshkarlekar Profile Picture
    1,678 on at
    action menu item not opening and giving error
    Unable to save data to the file "C:\Temp\Customer Cheque Deposit\CCSS__06/17/2025 11:00:59.txt".
      this is the error i am getting , please help me on this
  • Dineshkarlekar Profile Picture
    1,678 on at
    action menu item not opening and giving error
     i am trying to create the new file , i have made some code changes to do so.
    i have also did some changes to convert the text file using bin data but the session date i am getting wrong 1/1/1900 so my code is showing me error like cannot write to the file . i am posting my code below please suggest me  if i need any changes to do 
    internal final class CustomerChequeDepositJob
    {
        public static void main(Args _args)
        {
            ISLCustPDCRegister   pdcRegister;
            LedgerJournalTable   journalTable;
            LedgerJournalTrans   journalTrans;
            BankAccountTable     bankAccountTable;
    
            #File
    
            str                  filePath, fileName, cid, folderPath, baseFolder, folderName;
            str                  Narration1, Narration2, fullNarration;
            int                  lineCounter = 0;
            AmountCur            totalAmount = 0;
            str                  dataLine, headerLine, content;
            UtcDateTime          now = DateTimeUtil::getSystemDateTime();
            str                  timestamp;
            date        sessionDate;
            AmountCur            amount;
            BinData              binData = new BinData();
    
            try
            {
                // Base and target folder
                baseFolder = @"C:\Temp";
                folderName = "Customer Cheque Deposit";
                folderPath = baseFolder + "\\" + folderName;
    
                // Create folder if it doesn't exist
                //FileIOPermission permission = new FileIOPermission(folderPath, #io_write);
                //permission.assert();
                ARGlobal::CreateDirectory(folderPath);
    
                // Prepare company info and file name
                CompanyInfo companyInfo = CompanyInfo::find();
                cid = companyInfo.ARCIDNo;
    
                // Format timestamp: DDMMYYYYHHMMSS
                timestamp = System.String::Format('{0:ddMMyyyyHHmmss}', DateTimeUtil::newDateTime(systemDateGet(), timeNow()));
                fileName = strFmt("CCSS_%1_%2.txt", cid, timestamp);
                filePath = folderPath + "\\" + fileName;
    
                // Get session date in user's time zone
                sessionDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
    
                // Add CSV Header
                content = "S.No,CHQNAME_FRONT,CHQNAME_BACK,CHECKNUMBER,MICRNUMBER,BankRegNum,CompanyCID,BankAccount,MATURITYDATE,Amount,PaymentReference,Narration1,Narration2\r\n";
    
                // Loop through records
                while select ChqName_front,
                             ChqName_back,
                             CheckNumber,
                             MICRNumber,
                             MaturityDate,
                             PaymentReference,
                             BankAccount
                    from pdcRegister
                    join journalTable
                        where journalTable.JournalNum == pdcRegister.JournalNum
                    join Txt from journalTrans
                        where journalTrans.RecId == pdcRegister.LedgerJournalTrans
                       &&  pdcRegister.PDCStatus == ISLPDCStatus::Received
                       && pdcRegister.MaturityDate >= sessionDate
                {
                    bankAccountTable = BankAccountTable::find(pdcRegister.BankAccount);
                    amount = pdcRegister.displayAmount();
                    lineCounter++;
                    totalAmount += amount;
    
                    fullNarration = journalTrans.Txt;
                    Narration1 = subStr(fullNarration, 1, 35);
                    Narration2 = subStr(fullNarration, 36, 35);
    
                    dataLine = strFmt('%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13\r\n',
                                      lineCounter,
                                      pdcRegister.ChqName_front,
                                      pdcRegister.ChqName_back,
                                      pdcRegister.CheckNumber,
                                      pdcRegister.MICRNumber,
                                      bankAccountTable.RegistrationNum,
                                      companyInfo.ARCIDNo,
                                      bankAccountTable.AccountNum,
                                      date2str(pdcRegister.MaturityDate, 123, 2, 1, 2, 1, 4),
                                      amount,
                                      pdcRegister.PaymentReference,
                                      Narration1,
                                      Narration2);
    
                    content += dataLine;
                }
    
                // Add summary line
                headerLine = strFmt("\r\nTotal Records: %1, Total Amount: %2\r\n", lineCounter, totalAmount);
                content += headerLine;
    
                // Write to file
                binData.setStrData(content);
                binData.saveFile(filePath);
    
                CodeAccessPermission::revertAssert();
    
                info(strFmt("Export completed. %1 record(s) written to: %2", lineCounter, filePath));
            }
            catch (Exception::CLRError)
            {
                error("CLR error occurred.");
            }
            catch
            {
                error("Unhandled error occurred during export.");
            }
        }
    
    
    }
     
  • Martin Dráb Profile Picture
    234,615 Most Valuable Professional on at
    action menu item not opening and giving error
    You seems to be suggesting that you have some problem with the conversion, but you didn't tell us what problem. Please do it.
     
    And what exactly do you mean by "i am not getting the session date"?
     
    Please realize that we can't help you if you don't describe the problem.
     
    By the way, I hope you realized that using the file path isn't a feasible design for the cloud. You can use it temporarily for testing on T1, but you must change the approach before completing your development. Personally, I would use a more realistic solution from the beginning, because you risk introducing unnecessary problems with the files and permissions.
  • Dineshkarlekar Profile Picture
    1,678 on at
    action menu item not opening and giving error
    hi everyone i have created the job to test my service class but i m having issue in need to convert the file into text file
    2)i am using bindata to convert the test file 
    3)i am not getting the session date in my code 
    can you please check my code and suggest me corrections please 
    internal final class CustomerChequeDepositJob
    {
        public static void main(Args _args)
        {
            ISLCustPDCRegister   pdcRegister;
            LedgerJournalTable   journalTable;
            LedgerJournalTrans   journalTrans;
            BankAccountTable     bankAccountTable;
    
            #File
    
            str                  filePath, fileName, cid, folderPath, Narration1, Narration2, fullNarration;
            int                  lineCounter = 0;
            AmountCur            totalAmount = 0;
            str                  dataLine, headerLine, content;
            UtcDateTime          now = DateTimeUtil::getSystemDateTime();
            str                  timestamp;
            Date                 sessionDate;
            AmountCur            amount;
            BinData              binData = new BinData();
    
            try
            {
                // Update to an AOS-accessible path!
                folderPath = @"C:\Users\Desktop\d365";
    
                if (!System.IO.Directory::Exists(folderPath))
                {
                    error(strFmt("Export folder path not found: %1", folderPath));
                    return;
                }
    
                CompanyInfo companyInfo = CompanyInfo::find();
                cid = companyInfo.ARCIDNo;
    
                // Format timestamp as DDMMYYYYHHMMSS
                timestamp = System.String::Format('{0:ddMMyyyyHHmmss}', DateTimeUtil::newDateTime(systemDateGet(), timeNow()));
                fileName = strFmt("CCSS_%1_%2.txt", cid, timestamp);
                filePath = folderPath + "\\" + fileName;
    
                sessionDate = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
    
                // Header
                content = "S.No,CHQNAME_FRONT,CHQNAME_BACK,CHECKNUMBER,MICRNUMBER,BankRegNum,CompanyCID,BankAccount,MATURITYDATE,Amount,PaymentReference,Narration1,Narration2\r\n";
    
                while select ChqName_front,
                             ChqName_back,
                             CheckNumber,
                             MICRNumber,
                             MaturityDate,
                             PaymentReference,
                             BankAccount
                    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
                {
                    bankAccountTable = BankAccountTable::find(pdcRegister.BankAccount);
                    amount = pdcRegister.displayAmount();
                    lineCounter++;
                    totalAmount += amount;
    
                    fullNarration = journalTrans.Txt;
                    Narration1 = subStr(fullNarration, 1, 35);
                    Narration2 = subStr(fullNarration, 36, 35);
    
                    dataLine = strFmt('%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13\r\n',
                                      lineCounter,
                                      pdcRegister.ChqName_front,
                                      pdcRegister.ChqName_back,
                                      pdcRegister.CheckNumber,
                                      pdcRegister.MICRNumber,
                                      bankAccountTable.RegistrationNum,
                                      companyInfo.ARCIDNo,
                                      bankAccountTable.AccountNum,
                                      date2str(pdcRegister.MaturityDate, 123, 2, 1, 2, 1, 4),
                                      amount,
                                      pdcRegister.PaymentReference,
                                      Narration1,
                                      Narration2);
    
                    content += dataLine;
                }
    
                headerLine = strFmt("\r\nTotal Records: %1, Total Amount: %2\r\n", lineCounter, totalAmount);
                content += headerLine;
    
                // Write to file using BinData
                FileIOPermission permission = new FileIOPermission(filePath, #io_write);
                permission.assert();
    
                binData.setStrData(content);
                binData.saveFile(filePath);
    
                CodeAccessPermission::revertAssert();
    
                info(strFmt("Export completed. %1 record(s) written to: %2", lineCounter, filePath));
            }
            catch (Exception::CLRError)
            {
                error("CLR error occurred.");
            }
            catch
            {
                error("Unhandled error occurred during export.");
            }
        }
    
    }
     
  • Martin Dráb Profile Picture
    234,615 Most Valuable Professional on at
    action menu item not opening and giving error
    I'm not aware of any function called dateDay(), therefore I believe that compiler is right when saying that dateDay() doesn't exist. You could use DateTimeUtil::day(), but the whole thing isn't the best way of  converting a date time value to a string. The native X++ way is using DateTimeUtil::toFormattedStr(); I tend to use .NET formatting functions directly.
  • Ognjen Lapcevic Profile Picture
    101 on at
    action menu item not opening and giving error
     
    Did you maybe fix this line? Shouldn't it be ChequeDepositController?
    DepositController controller = ChequeDepositController::construct();

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 565

#2
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2025 Season 1

Product updates

Dynamics 365 release plans