Custom Snap

I can’t able to get the values from previous snap.I used mapper to set a value and retrieve using expression from previous snap but getting error alike cannot set null value.

@General(title = “Example snap”, purpose = “”, author = “”)
@Category(snap = SnapCategory.READ)
@Version(snap = 1)
@Inputs(min = 1, max = 1, accepts = { ViewType.DOCUMENT })
@Outputs(min = 1, max = 1, offers = { ViewType.DOCUMENT })
@Errors(min = 1, max = 1, offers = { ViewType.DOCUMENT })
public class ExampleSnap implements Snap
{

private static final String CACHE_DATA_ID = "Key";


private String Key;
private String valueCategory;



@Inject
private DocumentUtility documentUtility;

@Inject
private InputViews inputViews;
@Inject
private OutputViews outputViews;
@Inject
private ErrorViews errorViews;

@Override
public void defineProperties(final PropertyBuilder propBuilder)
{
	
	propBuilder.describe(CACHE_DATA_ID, CACHE_DATA_ID).expression().schemaAware(SnapProperty.DecoratorType.ACCEPTS_SCHEMA)
			.add();


}

@Override
public void configure(PropertyValues propertyValues) throws ConfigurationException
{
		valueCategory = propertyValues.getAsExpression(CACHE_DATA_ID).eval(null);
		
}

Please give some suggestion.

Hello,

We have posted a few blog posts regarding custom snap development on our website. I am sending you the URL for the 3 custom snaps developed by us that we have published so far, I believe you will find them useful. If you have any questions you can reach out to us.

Sleep snap: https://interworks.com.mk/development-of-custom-sleep-snap-for-snaplogic-platform/
Flow Reset snap: https://interworks.com.mk/development-of-a-custom-flow-reset-snap-for-the-snaplogic-platform/
Generic JDBC - Table Operation snap: https://interworks.com.mk/generic-jdbc-table-operation-custom-developed-snap/

Regards

1 Like

Hi,
Cant able to acces the URL’s above.

Many thanks for taking time and replying for the post.

Regards,
Ashlam

You’ll need to evaluate the ExpressionProperty against the input document, not null. This cannot be done in the configure() method, use process() instead:

ExpressionProperty valueCategoryExp;
String valueCategory;

@Override
public void configure(PropertyValues propertyValues) throws ConfigurationException {
	valueCategoryExp = propertyValues.getAsExpression(CACHE_DATA_ID);
}

@Override
protected void process(Document document, String s) {
        valueCategory = valueCategoryExp.eval(document);
}