Support Questions
Find answers, ask questions, and share your expertise

Get dynamic property name in execute script

Hi,

I am trying to make a Javascript code for the executeScript processor and I wonder if it's possible to get the name of a custom property added from the executeSript Properties tab.

I know that if I add a property "myProperty", I can access it from the script by using myProperty.getValue() (or with .evaluateAttributeExpressions() when needed).

But is it possible to find the key "myProperty" from inside the script ?

I would like to do something like

for(i = 0 ; i < customProperties.length ; i++){
	propertyName = customProperties[i].getName()
	value = propertyName.getValue()
	//Do something with propertyName and its value
}


Thanks in advance !
Félicien

10 REPLIES 10

If anyone needs it (Matt answers helped me a lot but is not exactly correct) :

for(var prop in context.properties) {
if(prop.isDynamic()) { var name = prop.getName(); var value = context.getProperty(name).evaluateAttributeExpressions(flowFile).getValue();
//or var value = context.getProperty(name).getValue(); if AttributeExpression are not needed log.info('name : ' + name + " value : " + value); }
}