How to handle 'Object reference not set to an instance of an object.'

Hi all,

I tentatively defined the following two Classes:

internal final class getDimensionValue
{
    public static str getDimensionDisplayValue(RecId defaultDimension, Name dimName)
    {
        DimensionAttributeValueSetStorage dimStorage;
        dimStorage = DimensionAttributeValueSetStorage::find(defaultDimension);
        return dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName(dimName).RecId);
    }
}
[ExtensionOf(formDataSourceStr(SalesTable, SalesTable))]
internal final class SalesTableForm_SalesTableDS_NewDelivery_Extension
{
    public int active()
    {
        int ret;
        str dimensionAttribute;
        SalesTable salesTable;

        ret = next active();

        dimensionAttribute = getDimensionValue::getDimensionDisplayValue(salesTable.DefaultDimension, 'CostCenter');
        Info(dimensionAttribute);

        return ret;
    }
}

Yes, I am trying to get the value of ‘CostCenter’ in the ‘active’ method of the SalesTable data source. I don’t know if this will achieve my goal, but I thought I should give it a try.

Then I got an error when testing:

When I clicked on the sales order details, the system reported this error.

I then tried to modify the two classes mentioned above, and even deleted them, but to no avail, the error still exists.

I don’t know how to fix this error :melting_face:, please help me.

First, try to debug & see from where this error is originating. It will give you the exact line causing error.
Second, do a model build once & see if the error goes away.