Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to close opened from using X++

(0) ShareShare
ReportReport
Posted on by 1,845

Hi ,

I am running a custom class in JOB . In class we are calling one Action menu item after completing the process. This is ok when user doing this process from Client .

But we have to do this process on more then 500 records. For every record its calling the menu item .

Any option to close that menu item before my second records is selected for process.

I already tried the below code

args.name(formstr(EcoResProductListPage));

formRun = ClassFactory.formRunClass(args);

formRun.init();

 

formRun.close();

*This post is locked for comments

  • Verified answer
    startax Profile Picture
    1,845 on at
    RE: How to close opened from using X++

    Hi

    I duplicated class Model 2 and commented the code that open Menu item

    MenuFunction(MenuItemDisplayStr(EcoResProductListPage),MenuItemType::Display).run();

    and used this duplicate class in our job. Problem is solved for now.

    I know this is not the best approach to solve this issue . We have to modify our Class for this for future use .

    Thanks for your valuable input.

  • startax Profile Picture
    1,845 on at
    RE: How to close opened from using X++

    Hi Sukrut,

    model 2 class doing some customization on product and then its calling Menu item

    MenuFunction(MenuItemDisplayStr(EcoResProductListPage),MenuItemType::Display).run();

    model 2 class is ok we don't have to make any change in that class.

  • startax Profile Picture
    1,845 on at
    RE: How to close opened from using X++

    static void _Product(Args _args)

    {

       EcoResProduct    product;

       DetailsTable   DetailsTable;

       Contract    contract;    // Class

       Model2       Model2;   // Class

       Table2        Table2;    // Table

       Args                            args;

       contract= new Contract    ();

       Model2= new Model2();

        args = new Args();

       while select DetailsTable where DetailsTable .EcoResCategory !=0

       {

           select product

               where product.DisplayProductNumber == DetailsTable .ProductCode

                                   && product.DisplayProductNumber == "ABC";

           if (product)

           {

               args.record(product);

               contract.parmRecId(args.record().RecId);

               contract.parmArgs(args);

               Model2.Data(contract);

           }

       }

    }

    This is my complete code and Model2 is class where I am doing operation on this product. Model2.Data(contract) is the method from where its calling menu item for every record processed.

    Actually this operation is performed from button click from product details form. But we have to do this for more than 500 records so its time consuming to do that one by one to all product .

    In production we don't have any option to make change in  Model2 class .

    @Rudi I already tried code suggested by you earlier with FormRun.Run().

    But this not worked .

    Actually form is opened by class not from Job code.

  • Suggested answer
    Rudi Hansen Profile Picture
    4,022 on at
    RE: How to close opened from using X++

    Just made the code for you anyway, you where missing a call to formRun.run()

    And if you neet to wait for the form to be closes, call fromRun.wait()

        Args    args = new Args();
        FormRun formRun;
        
        args.name(formstr(CustTable));
    
        formRun = ClassFactory.formRunClass(args);
    
        formRun.init();
        formRun.run();
        //formRun.wait();
    
        formRun.close();
    
  • Rudi Hansen Profile Picture
    4,022 on at
    RE: How to close opened from using X++

    What would be the point of you making a Job that opens and closes a form 500 times?

    It might be possible, but why would you do it?

  • Community Member Profile Picture
    on at
    RE: How to close opened from using X++

    Hi,

    Can you show us the full code?

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,997 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,831 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans