Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Get dynamic property name in execute script

avatar

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

1 ACCEPTED SOLUTION

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
10 REPLIES 10

avatar

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); }
}