cancel
Showing results for 
Search instead for 
Did you mean: 

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

rpatrick00
Contributor

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")
    .type(SnapType.STRING)
    .required()
    .expression(SnapProperty.DecoratorType.ACCEPTS_SCHEMA)
    .build();

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.

SnapLogic

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

Reason:

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

Hide Details...

SnapCompletionService
`com.snaplogic.snap.api.SnapDataException: Cannot lookup a property on a null value
	at sl.EvaluatorUtils.propertyRef(EvaluatorUtils.java:1331)
	at SC.evaluate(Unknown Source)
	at com.snaplogic.util.ExpressionUtils$MyExpressionProperty.eval(ExpressionUtils.java:281)
	at com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(PropertyValuesImpl.java:1005)
	at com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(PropertyValuesImpl.java:993)
	at com.tylertech.courtsandjustice.snaplogic.SnapLogicUtils.getNonEmptyStringProperty(SnapLogicUtils.java:136)
	at com.tylertech.courtsandjustice.snaplogic.OdysseyApiExecutionSyncXml.configure(OdysseyApiExecutionSyncXml.java:170)
	at com.snaplogic.cc.util.SnapUtil.configure(SnapUtil.java:392)
	at com.snaplogic.cc.snap.common.SnapRunnableImpl.configureSnap(SnapRunnableImpl.java:707)
	at com.snaplogic.cc.snap.common.SnapRunnableImpl.execute(SnapRunnableImpl.java:551)
	at com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:836)
	at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:402)
	at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:116)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.snaplogic.snap.api.SnapDataException: $ReferenceNumber is undefined
	at com.snaplogic.util.DefaultValueHandler.handleDefaultUndefinedReference(DefaultValueHandler.java:70)
	at com.snaplogic.util.DefaultValueHandler.handleUndefinedReference(DefaultValueHandler.java:65)
	at sl.EvaluatorUtils.propertyRef(EvaluatorUtils.java:1329)
	... 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?

1 REPLY 1

rpatrick00
Contributor

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…