Saturday 14 September 2013

Jumpref method in ax 2012


[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
}



Example:write the code in design field level :
public void jumpRef()
{
Args args = new Args();
//NetActivityTypes netActivityTypes;
;

args.caller(this);
//netActivityTypes = SalesTable::find(SalesLine.SalesId);
Args.record(netActivityTypes);

// Skip menuFunction declaration and run on the fly
new MenuFunction(menuitemdisplaystr(NetActivityTypes), MenuItemType::Display).run(args);

}

5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. can you please tell me what is the purpose of jumpref()

    ReplyDelete
    Replies
    1. to go to view details of form (setup form ) we can use this one
      Ex cust id 1101 ur using in ur form by using jumpref u can go the view details of particular customer details
      EX:right click on ur form 1101 select view details then it will goes 2 1101 customer detail form

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. can anyone post
    example with code,
    for any form/table

    ReplyDelete