How to define a Snap property field that will resolve a reference to a payload field

I have a custom snap that has a property that is defined as follows:

SnapProperty referenceNumberProperty = propertyBuilder.describe(REFERENCE_NUMBER_PROPERTY, REFERENCE_NUMBER_LABEL,
    "The reference number to associate with the API call")

I have inserted a top-level field in the payload called ReferenceNumber. If I enter $ReferenceNumber into the field, I can see the value added by the Mapper, as shown below.

However, when I save the changes, the validation fails with the error that $ReferenceNumber is null.


Value referenced in the sub-expression '$ReferenceNumber' is null

Hide Details...

`com.snaplogic.snap.api.SnapDataException: Cannot lookup a property on a null value
	at sl.EvaluatorUtils.propertyRef(
	at SC.evaluate(Unknown Source)
	at com.snaplogic.util.ExpressionUtils$MyExpressionProperty.eval(
	at com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(
	at com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(
	at com.tylertech.courtsandjustice.snaplogic.SnapLogicUtils.getNonEmptyStringProperty(
	at com.tylertech.courtsandjustice.snaplogic.OdysseyApiExecutionSyncXml.configure(
	at java.base/
	at java.base/java.util.concurrent.Executors$
	at java.base/
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.base/java.util.concurrent.ThreadPoolExecutor$
	at java.base/
Caused by: com.snaplogic.snap.api.SnapDataException: $ReferenceNumber is undefined
	at com.snaplogic.util.DefaultValueHandler.handleDefaultUndefinedReference(
	at com.snaplogic.util.DefaultValueHandler.handleUndefinedReference(
	at sl.EvaluatorUtils.propertyRef(
	... 18 more
Reason: Value referenced in the sub-expression '$ReferenceNumber' is null
Resolution: Please check expression syntax and data types.

Error Fingerprint[0] = efp:sl.WIPIHRfV
Error Fingerprint[1] = efp:com.snaplogic.util.XZSISSzX`

What do I need to do to allow this to work properly?

Nevermind, I figured it out. I needed to save the ExpressionProperty without evaluating it in the configure() method and then evaluate it against the document in the process method…