AX 7. QueryRangeFunctionAttribute as a replacement for SysQueryRangeUtil.

All of you are familiar with SysQueryRangeUtil class. It is really helpful when you need to use custom query ranges with AOT queries or advanced form filters (see TechNet for examples). However it is a part of Application Platform model now and you won’t be able to add new methods there soon, because this model will be locked for overlaying.

New QueryRangeFunctionAttribute is introduced to replace it. Now we can mark any public static method with this attribute and it becomes available everywhere you used to use SysQueryRangeUtil class. Let’s have a look at code example and its usage:

/// <summary>
/// Retrieves a list of field IDs that are valid inventory dimensions parameters.
/// </summary>
/// <returns>String representing a list of field IDs.</returns>
[QueryRangeFunctionAttribute()]
public static str includedFieldIds()
{
    Set             validFieldIds   = InventInventoryDimensionsParametersEntityHelper::getValidInventoryDimensionsParametersFieldIds();
    SetEnumerator   enumerator      = validFieldIds.getEnumerator();
    str             value;

    while (enumerator.moveNext())
    {
        value = queryRangeConcat(value, enumerator.current());
    }

    return value;
}

Untitled

As you can see, syntax is slightly changed, previously you should specify only method’s name and now you need to add class name as well, because any class can have such method.