Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Calling job from button

Posted on by Microsoft Employee

Hey all,

I have a requirement that i need to call a job from a button from.. let's say vendor form. I already have the job created. Now, i don't know how to implement this job to be called from a form's button. If there's a tutorial about this i hope you can put the link below on the comment box or if anyone have any kind of solution for this.

Thanks.

Anisa.

  • sohaibcheema Profile Picture
    sohaibcheema 46,594 User Group Leader on at
    RE: Calling job from button

    going back to basics of OOP

    1) enter by main method, of class

    2) initialize by creation of object of class.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calling job from button

    Anisa

    You can call a class just like how you did for the job. Everyone told you about moving code from job to a class because, jobs are usually written in ax to test or verify a logic before you actually implement it.

    A job may be overwritten by some one who is working in the same environment. A class on the other hand everyone knows is an implemented logic for some functionality. They won't bother to change it or overwrite it with new one.

    refer this link for learning more about classes : msdn.microsoft.com/.../aa868834.aspx

    calling a class from form button : msdn.microsoft.com/.../aa879186.aspx

  • Suggested answer
    Iulian Cordobin Profile Picture
    Iulian Cordobin 8,201 on at
    RE: Calling job from button

    You should be reading this: msdn.microsoft.com/.../aa631180.aspx and msdn.microsoft.com/.../aa673265.aspx.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calling job from button

    Thanks all, i've tried assign my job to action menu item, and put it on my form's button group. Why should i move my code to a class? if i already move it to a class, how can i call it? I mean, i call it from where? All of you just saying i should move my job to a class, but didn't explain how to call it, is it from form's control? Where, and how? Thanks.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calling job from button

    You can attach this job to an action menu item and map it to a menuitem button in the form. You will have to initialize the caller from _args object in job.

    Jens above said it correctly, You should be implementing your code in a class not a job.

  • Verified answer
    sohaibcheema Profile Picture
    sohaibcheema 46,594 User Group Leader on at
    RE: Calling job from button

    You can use two ways for that

    1. Call by Action menu item.

      Create an action menu item referring to your job and then call you action menu item

       

      MenuFunction menuFunction;
      
      menuFunction = new MenuFunction(menuItemActionStr(NameofYourActionMenu), MenuItemType::Action);
      menuFunction.run();

    2. Call by X++

       

       

      Note: above both ways are not recommended. Consider migrating your code into a class.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calling job from button

    You should move your code to a class and call the class.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans