Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Calling a form using batch jobs in Dynamics Ax 2012

(0) ShareShare
ReportReport
Posted on by 109

 I want to call a form in batch job using RunBaseBatch but I am getting an error.

I have simple code in RunBaseBatch class.:

public void doIt()
{
  Args args = new Args();

  new MenuFunction(menuItemOutputStr(LedgerBalanceSheetDimPrint), MenuItemType::Output).run(args);

}

I get the error after CIL and Restart.:

This menu item calls the Ax standard LedgerBalanceSheetDimPrint class.

Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException' was thrown.

at Dynamics.Ax.Application.RunBase.promptOnClient(Int32 classId, Object[] packed)

at Dynamics.Ax.Application.RunBase.Promptprim() in RunBase.promptPrim.xpp:line 16

at Dynamics.Ax.Application.RunBase.Prompt() in RunBase.prompt.xpp:line 12

at Dynamics.Ax.Application.RunBaseBatch.Prompt() in RunBaseBatch.prompt.xpp:line 30

at Dynamics.Ax.Application.LedgerBalanceSheetDimPrint.main(Args args) in LedgerBalanceSheetDimPrint.main.xpp:line 11

at LedgerBalanceSheetDimPrint::Main(Object[] )

at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)

at Dynamics.Ax.Application.MenuFunction.Run(xArgs _args, Boolean ) in MenuFunction.run.xpp:line 76

at Dynamics.Ax.Application.MenuFunction.Run(xArgs _args)

at Dynamics.Ax.Application.AutoGenerateReportsYearly.Doit() in AutoGenerateReportsYearly.doIt.xpp:line 7

at Dynamics.Ax.Application.AutoGenerateReportsYearly.Run() in AutoGenerateReportsYearly.run.xpp:line 15

at Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) in BatchRun.runJobStaticCode.xpp:line 54

at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) in BatchRun.runJobStatic.xpp:line 13

at BatchRun::runJobStatic(Object[] )

at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)

at BatchIL.taskThreadEntry(Object threadArg)



I also get this error when I try the same operation with SysOperation class.

Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException' was thrown.

at Dynamics.Ax.Application.RunBase.promptOnClient(Int32 classId, Object[] packed)

at Dynamics.Ax.Application.RunBase.Promptprim() in RunBase.promptPrim.xpp:line 16

at Dynamics.Ax.Application.RunBase.Prompt() in RunBase.prompt.xpp:line 12

at Dynamics.Ax.Application.RunBaseBatch.Prompt() in RunBaseBatch.prompt.xpp:line 30

at Dynamics.Ax.Application.LedgerBalanceSheetDimPrint.main(Args args) in LedgerBalanceSheetDimPrint.main.xpp:line 11

at LedgerBalanceSheetDimPrint::Main(Object[] )

at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)

at Dynamics.Ax.Application.MenuFunction.Run(xArgs _args, Boolean ) in MenuFunction.run.xpp:line 76

at Dynamics.Ax.Application.MenuFunction.Run(xArgs _args)

at Dynamics.Ax.Application.KlForCustTesterDataService.Testcustomer(KlForCustTesterDataContract _klForCustTesterDataContract) in KlForCustTesterDataService.testCustomer.xpp:line 5

at KlForCustTesterDataService::testCustomer(Object , Object[] )

at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeInstanceCall(Object instance, String MethodName, Object[] parameters)

at Microsoft.Dynamics.Ax.Xpp.DictClass.Callobject(String _methodName, XppObjectBase _Called, Object[] varArgs)

at Dynamics.Ax.Application.SysOperationServiceController.Runoperation(Boolean _async) in SysOperationServiceController.runOperation.xpp:line 88

at Dynamics.Ax.Application.SysOperationServiceController.Run() in SysOperationServiceController.run.xpp:line 27

at Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) in BatchRun.runJobStaticCode.xpp:line 54

at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) in BatchRun.runJobStatic.xpp:line 13

at BatchRun::runJobStatic(Object[] )

at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)

at BatchIL.taskThreadEntry(Object threadArg)

By calling this form, I have it save the data on the screen to an Excel file. It works when I call it with menu item.

Version is Dynamcis ax 2012 R2 6.2.1000.4051

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,516 Super User 2025 Season 1 on at
    RE: Calling a form using batch jobs in Dynamics Ax 2012

    Hi Faruk,

    I don't know the details of this form, but all calculations can be done in classes. I don't know what exact logic you have on this form, but might it be on the wrong place. You can then decide to have SSRS for a report or export to file.

  • Faruk Durak Profile Picture
    Faruk Durak 109 on at
    RE: Calling a form using batch jobs in Dynamics Ax 2012

    I have to use the form because I'm exporting the data from the form to an Excel. I have complex data on the form and it takes a lot of time to do this with SSRS. Menu item invokes a class, class invokes form. I export the forms to Excel file. Could there be another way to do this?

  • Martin Dráb Profile Picture
    Martin Dráb 231,409 Most Valuable Professional on at
    RE: Calling a form using batch jobs in Dynamics Ax 2012

    Wouldn't it be better if you bypassed the form?

    What's the exact thing that you're unable to implement without taking dependency on the graphical user interface?

  • Faruk Durak Profile Picture
    Faruk Durak 109 on at
    RE: Calling a form using batch jobs in Dynamics Ax 2012

    Hello Martin and André,

    Thank you for your answers. I suggested to my client that we can't do this with batches and that we can develop a Windows Service application instead of a batch job. The .Net Business Connector will fix this. Thanks.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,516 Super User 2025 Season 1 on at
    RE: Calling a form using batch jobs in Dynamics Ax 2012

    Hi Faruk,

    As mentioned by Martin, this is not possible. It looks like you are not trying to open a form, but want to start running a report. From the batch job, it would be possible to add the report execution as new batch job via coding.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 231,409 Most Valuable Professional on at
    RE: Calling a form using batch jobs in Dynamics Ax 2012

    It's not possible. Forms run on client and there is no client when executing code on the batch server.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans