# Is it possible to do nested calls of event fields?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-do-nested-calls-of-event-fields/225219>\
**Category:** Logstash\
**Created:** [March 26, 2020, 2:54pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-nested-calls-of-event-fields/225219 "2020-03-26T14:54:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidanoc15](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@aidanoc15](https://discuss.elastic.co/u/aidanoc15)\
**Post date:** [March 26, 2020, 2:54pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-nested-calls-of-event-fields/225219/1 "2020-03-26T14:54:27Z")

</div>

I'm not sure if I am really phrasing the issue I am having correctly, so let me show you an example of what I am trying to do and maybe you can tell me if this is possible in logstash.

```auto
add_field => { "[variables][companyIdentifier]" => "%{[cw_auth][hits][hits][0][_source][connectwise][company_ids][%{client}][id]}" }

```

As you can see, I am trying to pass in the value of one event field as part of the key for another event field. This is currently not working and [variables][companyIdentifier] just becomes the string "%{[cw\_auth][hits][hits][0][\_source][connectwise][company\_ids][%{client}][id]}."

My suspicion is that this most likely is not directly possible, but I was wondering if there might be some work around involving a ruby code or something that could accomplish this?

Any help is appreciated, thanks in advance.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [March 26, 2020, 5:44pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-nested-calls-of-event-fields/225219/2 "2020-03-26T17:44:04Z")

</div>

> [@aidanoc15](#):
>
> I was wondering if there might be some work around involving a ruby code

The following is not tested, but should give you an idea:

```
code => '
    clientid = event.get("client")
    ids = event.get("[cw_auth][hits][hits][0][_source][connectwise][company_ids]")
    event.set("[variables][companyIdentifier]", ids[#{client}]["id"]}
'

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 23, 2020, 5:44pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-nested-calls-of-event-fields/225219/3 "2020-04-23T17:44:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
