jumpref() in Dynamic AX
[AX 2012] The table does not exist as a root FormDataSource for the form
If you are Receiving this error: “Could not process the lookupTable value on the Args instance. The table ‘TableName’ does not exist as a root FormDataSource for the form ‘TableNameForm’” I may have found a solution for you.
AX 2012 gets very angry when you call a form using a record from a datasource that is not the main form datasource. For example, if you have a form with SalesTable and SalesLine joined to it, and you call the form with a SalesLine record, this error message will pop-up. If this is for View Details, The easiest way to fix this is as follows:
1. Override the jumpRef() on the datasource field
2. Create Args and MenuFunction variables
3. Find the record for the main datasource table
4. Set args.record() to the main datasource record
5. Set menuFunction to the menu item that would be called if you went to View Details
6. Call the menu item with args
For form buttons, override the clicked() and continue following steps 2 through 6.
View Details Example:
public void jumpRef()
{
Args args = new Args();
SalesTable salesTable; // that we are using not in the datasource list or it can be
;
args.caller(this);
salesTable = SalesTable::find(SalesLine.SalesId);
Args.record(salesTable);
// Skip menuFunction declaration and run on the fly
new MenuFunction(menuitemdisplaystr(SalesTable), MenuItemType::Display).run(args); //menuitem name of that form that is to ref
}
Ref://http://dynamicsaxtipsandtricks.wordpress.com/
If you are Receiving this error: “Could not process the lookupTable value on the Args instance. The table ‘TableName’ does not exist as a root FormDataSource for the form ‘TableNameForm’” I may have found a solution for you.
AX 2012 gets very angry when you call a form using a record from a datasource that is not the main form datasource. For example, if you have a form with SalesTable and SalesLine joined to it, and you call the form with a SalesLine record, this error message will pop-up. If this is for View Details, The easiest way to fix this is as follows:
1. Override the jumpRef() on the datasource field
2. Create Args and MenuFunction variables
3. Find the record for the main datasource table
4. Set args.record() to the main datasource record
5. Set menuFunction to the menu item that would be called if you went to View Details
6. Call the menu item with args
For form buttons, override the clicked() and continue following steps 2 through 6.
View Details Example:
public void jumpRef()
{
Args args = new Args();
SalesTable salesTable; // that we are using not in the datasource list or it can be
;
args.caller(this);
salesTable = SalesTable::find(SalesLine.SalesId);
Args.record(salesTable);
// Skip menuFunction declaration and run on the fly
new MenuFunction(menuitemdisplaystr(SalesTable), MenuItemType::Display).run(args); //menuitem name of that form that is to ref
}
Ref://http://dynamicsaxtipsandtricks.wordpress.com/
No comments:
Post a Comment