Below is the example I created for demonstrating how to call a menu item from X++. In this example I'm calling sales packing slip menu item for posting sales packing slip for all lines.
class SW_TestClassDebug
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
MenuFunction menuFunction;
salestable _SalesTable = SalesTable::find("SO00125111");
Args args = new Args();
args.record(_SalesTable);
menuFunction = new MenuFunction(menuitemActionStr(SalesFormLetter_PackingSlip), MenuItemType::Action);
if (menuFunction && menuFunction.checkAccessRights())
{
menuFunction.run(args);
}
}
}
class SW_TestClassDebug
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
MenuFunction menuFunction;
salestable _SalesTable = SalesTable::find("SO00125111");
Args args = new Args();
args.record(_SalesTable);
menuFunction = new MenuFunction(menuitemActionStr(SalesFormLetter_PackingSlip), MenuItemType::Action);
if (menuFunction && menuFunction.checkAccessRights())
{
menuFunction.run(args);
}
}
}
I high appreciate this post. It’s hard to find the good from the bad sometimes, but I think you’ve nailed it! would you mind updating your blog with more information? link
ReplyDelete