menuitem disappears when called through X++ coding


menuFunction = new MenuFunction(menuItemOutputStr(ledgerjournal), MenuItemType::Output);
if (menuFunction && menuFunction.checkAccessRights())

The above code executes but menu item i am calling pops and suddenly disappears after the coding executes.

Can someone help me to find the exact solution.

It seems that you mean that the dialog opened by LedgerJournalController class (which is what your menu item calls) gets open but then it’s closed again. I’m not sure what you mean by “after the coding executes” - the dialog is open inside run() and the code doesn’t complete until the dialog is closed.
Please tell us more about the observed behavior and consider debugging what happens inside the class (because your problem seems to be there, not in the calling code you showed above).