sg_sripathi
6 years agoNew Contributor III
SnapLogic SDK - Accessing pipeline properties and parameters
Hi,
I am writing a custom snap in which I would like to get the pipeline name, runtime id and few predefined path parameter. I do not want to capture these as snap level properties for user to conf...
- 6 years ago
Hello @sg_sripathi, good question and yes this can be done.
Inject the expression utility class:
@Inject private ExpressionUtils expressionUtils; String pipeLabel;
then in the
configure()
method:@Override public void configure(PropertyValues propertyValues) throws ConfigurationException { Document emptyDoc = documentUtility.newDocument(); pipeLabel = expressionUtils.createExpressionProperty( propertyValues, true, "pipe.label").eval(emptyDoc); }
And then you can just use the variable when writing an output document e.g.:
Map<String, String> data = new LinkedHashMap<String, String>() {{ put("pipeLabel", pipeLabel); }}; outputViews.write(documentUtility.newDocument(data));
The Mapper Snap can be used to validate whatever expression value you are trying to use in the custom Snap: