Thursday, October 4, 2012

AX2012 jumpRef in Sys Operation Framwork


In AX2012, if you have an SSRS report that has parameters and you want to customize the “go to main table functionality” of a parameter, here’s how to do it:
In the UI builder of the report, override the postRun() method:

/// <summary>
///     This method registers the dialog field methods to capture events.
/// </summary>
public void postRun()
{
    Dialog dialogLocal = this.dialog();
    DialogField dialogField;

    super();

     // This method should be called in order to handle events on dialogs.
    dialogLocal.dialogForm().formRun().controlMethodOverload(false);

    dialogField = this.bindInfo().getDialogField(this.dataContractObject(),
        methodstr(CustTableReportContract, parmCustTable));
   
    // Override the default jumpRef to use custTableJumpRef.
    dialogField.registerOverrideMethod(methodstr(FormStringControl, jumpRef),
        methodstr(CustTableReportUIBuilder, custTableJumpRef), this);
}


Add a method custTableJumpRef() to be used in place of the default jumpRef of the control, this can be added to the UI builder class of the report:

/// <summary>
///    Provides go to main table (View Details) functionality.
/// </summary>
public void custTableJumpRef()
{
    MenuFunction    menuFunction;
    Args            args = new Args();
   
    menuFunction = new MenuFunction(menuitemDisplayStr(CustTable), MenuItemType::Display);   
   
    // Pass the record selected in the lookup here.
    args.lookupRecord(CustTable::find('4000'));
   
    // If you don't want to pass any queries to the jumpRef form.
    menuFunction.copyCallerQuery(CopyCallerQuery::No);
   
    // Call the jumpRef form.
    menuFunction.run(args);
}

This can be used to override any number of default methods of control to provide customized functionality e.g. lookup.

The Sys Operation Framework (formerly known as the Business Operation framework, or BOF) also follows the same pattern; so you can use the above example in that as well.