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)

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

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi,

    Can you show us the full code?

  • Rudi Hansen Profile Picture
    4,075 on at

    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?

  • Suggested answer
    Rudi Hansen Profile Picture
    4,075 on at

    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();
    
  • startax Profile Picture
    1,845 on at

    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.

  • startax Profile Picture
    1,845 on at

    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.

  • Verified answer
    startax Profile Picture
    1,845 on at

    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.

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