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)

Error Passing args through MenuFunction in a SysOperational Base Class

(0) ShareShare
ReportReport
Posted on by 160

Hello Everyone,

I am a beginner at MS Dynamics AX , and am stuck at something i.e. I want to call a menu item through a batch job through a menuFunction, I also have to pass the current record as an arg to the menu Item. I am using the following code for it,

Args args = new Args();

args.record(custPackingSlipJour);
menufunction = new MenuFunction(menuItemOutputStr(SalesPackingSlip), MenuItemType::Output);
menuFunction.run(args);

but it is giving me the error : Expected type is str whereas encountered type is date. The called from property of each of the class,menuitem is 'called from' .

P.S. The same code is working fine in a simple Job.

*This post is locked for comments

I have the same question (0)
  • jasman Profile Picture
    1,413 on at

    I am assuming a 2012 versions.
    Have you done CIL-compile before running the batch job ?

  • AbdulKhaliq Profile Picture
    160 on at

    Yes, I have.

  • Brandon Wiese Profile Picture
    17,788 on at

    Presumably you're trying to print or render to a file the specific CustPackingSlipJour record.  Are you interested in some other ways to accomplish that without using MenuFunction?

  • AbdulKhaliq Profile Picture
    160 on at

    I am trying to use print management(send emails to customers) through a batch job, my Menu Item item points to the Controller Class and I have tried to directly call that class but it is not working. What other way can I do it ?

  • Brandon Wiese Profile Picture
    17,788 on at

    Yes, you can call the controller class directly.

  • AbdulKhaliq Profile Picture
    160 on at

    I have tried that but it gives me some other error i.e.  something like - >No screen to show the report although I am not trying to show the report.

  • Suggested answer
    Brandon Wiese Profile Picture
    17,788 on at

    Take a look at the class EPSendDocument method makeDocument().

    You probably want to use args.parmEnum(PrintCopyOriginal::OriginalPrint) instead, in which case the print settings probably shouldn't matter.

    The code actually doesn't support Sales order or Free text invoices properly, but since you're doing a Sales order packing slip, it should work.  I haven't done exactly what you're wanting, but I have generated directly to PDF files from X++ code in many, many projects using similar code.

  • AbdulKhaliq Profile Picture
    160 on at

    Thanks.

    Tried it, it gives the same error i.e. Cannot render the report to the screen when running in non-client mode . I dont want the report to show to screen.

  • Brandon Wiese Profile Picture
    17,788 on at

    If you navigate to the record in AX, using the Sales packing slip journals form, and click Print/Preview, then Use print management, what happens?  Does it print to screen or send an e-mail?

  • AbdulKhaliq Profile Picture
    160 on at

    It sends an email with packing slip attached and shows infolog confirming it.

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