Microsoft Dynamics 365 Blog

Recently we found an “Invalid Range” error to logged when using drill through on an AX SRS Report we created for a custom table following the documentation at the link below:

    “How to: Add a URL Drill Through Action” http://msdn.microsoft.com/en-US/library/cc582049.aspx

From further investigation we found the the hardcoded 1 at indexFields.Add method from the code below to be the cause. The number is not referencing the order of the fields in the unique (composit) index but is a reference to the fieldnumber of the field in the table. For CustTable accountNumber used in the sample code this appear to be 1. For fields in custom tables this is rarely the case

Just to clear up the confusion.

[DataMethod(), AxSessionPermission(SecurityAction.Assert)]
public static string AccountNumberUrl(string context, string accountNumber)
{
    Dictionary<int, object> indexFields = new Dictionary<int, object>();
    indexFields.Add(1, accountNumber);
    int tableId = 77;

    // Check whether the context is the client. If so, generate a
    // URL to display the CustTable form.
    if (RuntimeReportContext.IsClientContext(context))
    {
        return DynaLink.GenerateURL(context, “CustTable”, MenuItemType.Display, tableId, indexFields);
    }

    // Check whether the context is EP. If so, generate a URL to
    // display the EPCustTableInfo Web menu item.
    else if (RuntimeReportContext.IsEPContext(context))
    {
        return DynaLink.GenerateURL(context, “EPCustTableInfo”, MenuItemType.WebMenuItemTypeUrl, tableId, indexFields);
    }
    return string.Empty;
}

 

–author: Jago van der Most
–editor: Jago van der Most
–date: 25/Feb/2011

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!