I've been stuck on this for far too long. I've used every resource I could find.
myVariable_current.OrderItem__c.OLI_Final_Amount_3__c because it hasn't been set or assigned
I have a PB that fires when an entitlement is updated with no criteria. The pb updates a field on the entitlement based on a formula (can't do as a formula field as it references its self).
The error first started appearing when using db amp to run some ETL. This error is not reproducible while using the ui for any of the records that failed to update via db amp. Manually applying the changes works.
I had stopped caring about the db amp failures as in all situations the value that would be calculated was 0 which is the value we wanted.
Now I'm seeing this error in a test class and I cannot for the life of me figure it out.
This is the formula:
IF(
[Entitlement].SuppressFromEntitlementReport__c,
0,
IF(
AND(
[Entitlement].OrderType__c='Extension',
NOT(ISBLANK([Entitlement].RenewedFrom__c))
),
IF(
AND(
[Entitlement].RenewedFrom__c.OrderType__c='Extension',
NOT(ISBLANK([Entitlement].RenewedFrom__c.RenewedFrom__c))
),
IF(
[Entitlement].RenewedFrom__c.RenewedFrom__c.OrderType__c='Extension',
0,
[Entitlement].RenewedFrom__c.RenewedFrom__c.AnnualAmount__c
),
[Entitlement].RenewedFrom__c.AnnualAmount__c
),
IF (
AND(
NOT(ISBLANK([Entitlement].OrderItem__c)),
NOT(ISBLANK([Entitlement].OrderItem__c.OLI_Final_Amount_3__c)),
[Entitlement].OrderItem__c.OLI_Final_Amount_3__c != 0
),
IF (
AND(
[Entitlement].TermInDays__c > 363,
[Entitlement].TermInDays__c < 366
),
IF(
[Entitlement].OrderItem__c.Quantity__c = [Entitlement].OrderItem__c.EntitlementQuantity__c,
IF(
[Entitlement].OrderItem__c.Quantity__c = [Entitlement].Quantity__c,
[Entitlement].OrderItem__c.OLI_Final_Amount_3__c,
[Entitlement].OrderItem__c.OLI_Final_Amount_3__c / [Entitlement].OrderItem__c.EntitlementQuantity__c * [Entitlement].Quantity__c
),
[Entitlement].OrderItem__c.OLI_Final_Amount_3__c / [Entitlement].OrderItem__c.EntitlementQuantity__c * [Entitlement].Quantity__c
),
IF(
[Entitlement].OrderItem__c.Quantity__c = [Entitlement].OrderItem__c.EntitlementQuantity__c,
IF(
[Entitlement].OrderItem__c.Quantity__c = [Entitlement].Quantity__c,
[Entitlement].OrderItem__c.OLI_Final_Amount_3__c,
[Entitlement].OrderItem__c.OLI_Final_Amount_3__c / [Entitlement].OrderItem__c.EntitlementQuantity__c * [Entitlement].Quantity__c
) / (
IF(
[Entitlement].TermInDays__c=0,
1,
[Entitlement].TermInDays__c
)
) * 364,
(
(
[Entitlement].OrderItem__c.OLI_Final_Amount_3__c / [Entitlement].OrderItem__c.EntitlementQuantity__c * [Entitlement].Quantity__c
) / (
IF(
[Entitlement].TermInDays__c=0,
1,
[Entitlement].TermInDays__c
)
)
) * 364
)
),
0
)
)
)
Notice I run several null checks in the correct order in accordance with SF documentation.
I added this formula as a criteria to no avail either:
OR(
[Entitlement].OrderType__c='Extension',
AND(
NOT(ISBLANK([Entitlement].OrderItem__c)),
NOT(ISBLANK([Entitlement].OrderItem__c.OLI_Final_Amount_3__c)),
[Entitlement].OrderItem__c.OLI_Final_Amount_3__c != 0
)
)
EDIT:
In attempting Croredy's advice, I stripped the formula all the way down to:
IF (
AND(
NOT(ISBLANK([Entitlement].OrderItem__c)),
NOT(ISBLANK([Entitlement].OrderItem__c.OLI_Final_Amount_3__c))
),
1,
0
)
This is the smallest formula that doesn't work. Removing the line referencing OLI_Final_Amount_3__c resolves the issue.
Note: OLI_Final_Amount_3__c is a very simple formula field. I updated it to look like
BLANKVALUE(IF(
OR(Product__r.Product_Master__r.Summary_Level_Product_Name__c = "VMS",
CONTAINS(Product__r.Name , "UVM"),
CONTAINS(Product__r.Name , "651"),
CONTAINS(Product__r.Name , "1505"),
CONTAINS(Product__r.Name , "200")),
VAR_VAD_Subtotal__c , Discounted_Subtotal__c ),0)
to ensure that it always has a non-null value but the issue persists.
It seems like I'm doing exactly what the documentation says to do, and it's not working.
To reiterate, this issue only seems to appear when updating via DB Amp and only one of my unit tests. I cannot reproduce it manually.
EDIT:
Another apparently pointless effort:
IF (
NOT(ISBLANK([Entitlement].OrderItem__c)),
IF (
NOT(ISBLANK([Entitlement].OrderItem__c.OLI_Final_Amount_3__c)),
1,
0
),
0
)
This fails as well.
Oli_Final_Amount_3__c
is actually returning#Error
- this might be masked in the standard UI. Create a real record matching the testmethod and display the value ofOli_Final_Amount_3__c
in a report (where #Error will appear)