Thanks Andy, but with expression language I can only get values of attributes and not both key and value. In our case , variable key also has some useful information.
Thanks On Mon, Aug 10, 2020 at 10:32 PM Andy LoPresto <[email protected]> wrote: > Those variables are available to be referenced via Expression Language in > the flowfile attributes. They are not intended for direct programmatic > access via code, so you don’t need to address them directly in your Groovy > code. > > If you need to populate specific values at configuration time, you can > define dynamic properties on the processor config and reference those > directly in code (see any existing processor source for examples). > > Andy LoPresto > [email protected] > *[email protected] <[email protected]>* > He/Him > PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > > On Aug 9, 2020, at 10:40 PM, Saloni Udani <[email protected]> > wrote: > > Thanks Andy. > > By variables I meant NiFi process group variables. > <Screenshot from 2020-08-10 11-08-15.png> > > On Sat, Aug 8, 2020 at 12:39 AM Andy LoPresto <[email protected]> > wrote: > >> I think we need additional clarification on what you mean by “variables”. >> If you are referring to actual Groovy variables, you can enumerate them >> using the binding available in the context (see below). If you mean the >> attributes available on a flowfile, you can access them similarly. >> >> Find all variables starting with prefix: >> >> def varsStartingWithABC = this.binding.variables.findAll { k,v -> >> k.startsWith(“a.b.c”) } >> >> Find all attributes starting with prefix: >> >> def attrsStartingWithABC = flowfile.getAttributes().findAll { k,v -> >> k.startsWith(“a.b.c”) } >> >> >> >> Andy LoPresto >> [email protected] >> *[email protected] <[email protected]>* >> He/Him >> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 >> >> On Aug 7, 2020, at 2:11 AM, Saloni Udani <[email protected]> >> wrote: >> >> Hi, >> We use NiFi 1.5.0. >> Our use case is to get particular key pattern variables (key and value) >> in the groovy InvokeScriptedProcessor. E.g I want all variables whose key >> starts with "a.b.c". By this I can write a generic logic on certain >> categories of variables for further use. >> >> Is there a way programmatically to get all variables with a certain key >> pattern? Or for that matter is there a way programmatically to get all >> available variables Map ? In NiFi 1.5.0 or further versions. >> >> >> Thanks >> Saloni Udani >> >> >> >
