AX / D365FO – how to handle null value string column of a View in X++

Sometimes an outer join is necessary in a query to enrich the resulting records with additional data but the fields can also have NULL since they come from an outer join and some records may not exist!

To solve the issue you can create a computed field in your view and use SQL ISNULL() function

Here is an example :

Create a new method in your view and write below code

public class OTS_APS_OpenSalesOrdersView extends common
{
    public static str Norm_SupplyConditionGroup()
    {
        str ret;
        str SupplyConditionGroup = SysComputedColumn::returnField(identifierStr(OTS_APS_OpenSalesOrdersView), identifierStr(OTS_APS_LAM_SupplyConditionGroup),identifierStr(SupplyConditionGroup));

        ret = "isnull(" + SupplyConditionGroup + ",'')";

        return ret;
    }
}

Now create a computed column and add method in ViewMethod property

SQL View Definition will look like this

Leave a comment