Replicate menuItem by x++

Im trying to call a menuItem by code, but looks like I’m missing

args.record().dataSource()


When I call the BOMReportFinished (action) from a button I have a args.record().dataSource() returning true.

but when I call it from code like this:

args.record(inventsum::find(“C-1202BCA-B”,‘0087361’));

new MenuFunction(MenuItemActionStr(BOMReportFinished),MenuItemType::Action).run(Args);

args.record().dataSource() return false;

Do I need to add something to my args to have args.record().dataSource() return true;

Thanks

First of all, it doesn’t return boolean - it returns an instance of FormObjectSet class, i.e. a form data source. Because your record didn’t come from a form data source, there is no such object available. You can also use isFormDataSource() method to do the check (which actually returns true/false).