nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Carenza <nick.care...@thecontrolgroup.com>
Subject Re: ExecuteScript Javascript flowFile.getAttributes()
Date Thu, 12 Apr 2018 21:28:53 GMT
Great, thank you. That does work.

On Thu, Apr 12, 2018 at 11:53 AM, Matt Burgess <mattyb149@apache.org> wrote:

> Nick,
>
> Here's a example slightly modified from my cookbook example (I'm not
> sure that works with the array brackets, might need to use .get()
> instead), this one is a full working script to log each attribute:
>
> var flowFile = session.get()
> if (flowFile != null) {
>     var attrs = flowFile.getAttributes();
>     for each (var attr in attrs.entrySet()) {
>        log.info("Attribute " + attr.getKey() + " = " + attr.getValue());
>   }
>   session.transfer(flowFile, REL_SUCCESS);
> }
>
> Regards,
> Matt
>
>
> On Thu, Apr 12, 2018 at 2:18 PM, Nick Carenza
> <nick.carenza@thecontrolgroup.com> wrote:
> > Hey users,
> >
> > I am having trouble getting attributes from my flowfiles as described
> here
> > https://community.hortonworks.com/articles/75032/
> executescript-cookbook-part-1.html.
> >
> > Does anyone have a working example they could share of getting and
> iterating
> > through all of a flowfile's attributes in javascipt?
> >
> > Thanks.
> > Nick
>

Mime
View raw message