Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

[SysOperationFrameWork] Call MenuItem/Job by X++

Posted on by Microsoft Employee

Good morning,

i developed several jobs using the SysOperationFrameWork. This jobs can be started by simply clicking the menu item or by X++ during certain processes.

Now i wonder if i can use the "old" MenuFunction method to call this job by code because the calling procedure for SysOperation-jobs differs from RunBaseBatch. My job takes a WaveId as a parameter.

How would you call a SysOperation by X++?

Regards

Nils

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 229,928 Most Valuable Professional on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    I'm sorry, but I can't comment on the error without any information about it. Please share the error message with us and look at which piece of code is throwing it.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    Hi Martin, I also have a small question similar to Nils. I used MenuFunction to call a Lasernet class through following line of code.

    new MenuFunction(menuItemActionStr(LACResendReportPreview), MenuItemType::Action).run(args);

    This works well when i run it as a job but when i do the same thing in Batch job and schedule it. this line of code throw error. 

    Is there any other way to call a actionMenuItem in a batch job.



  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    @Amrita Bhattacharjee

    sorry i missed you post.

    Yes this should work for me now

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    you are right

    [DataContractAttribute] was missing in the class declaration. It was the only Contract class where this metadata was missing. Strange that i didn't get this error earlier

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    I will try that

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 229,928 Most Valuable Professional on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    "No metadata class defined for data contract object" means that your data contract is invalid. The most common reason is forgetting to decorate the contract class with the DataContractAttribute.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    Try this

    SalesTable salesTable= SalesTable::find('QFCA-000002');  

    Args args = new Args();     

       

    args.record(salesTable);     

    args.caller();     

    new MenuFunction(menuitemDisplayStr('SalesLine'), MenuItemType::Display).run(args);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    Here is an example of what happens if i try to run the job via MenuFunction. I think i have to pass a DataContract somehow but don't know where.

    static void Job26(Args _args)
    {
        Args args = new args();
        
        args.record(WHSWaveTable::find("CHWAWV0000000093"));
        
        new MenuFunction(menuitemActionStr(KVCleanupSorterService), MenuItemType::Action).run(args);
    }

    Error:
    6735.error.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    Edit:

    In my case i just needed the funtionality of a method, not the other things provided by the SysOperationFramework. I wasn't clear about this.

  • Martin Dráb Profile Picture
    Martin Dráb 229,928 Most Valuable Professional on at
    RE: [SysOperationFrameWork] Call MenuItem/Job by X++

    That doesn't really explain your code that caused "an error in the controller class because it had no DataContract".

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,134 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans