# Nested Query on Managers

**URL:** <https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435>\
**Category:** SHF Discussion and Questions\
**Created:** [August 18, 2022, 3:42pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435 "2022-08-18T15:42:36Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![bostelmann](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bostelmann](https://developer.sailpoint.com/discuss/u/bostelmann)\
**Post date:** [August 18, 2022, 3:42pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/1 "2022-08-18T15:42:37Z")

</div>

Is it possible to query identities who have managers in an ‘inactive’ Lifecycle State?

If so, can you conduct this query through the Search UI and API, and what would the query look like?

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [August 19, 2022, 2:03pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/2 "2022-08-19T14:03:56Z")

</div>

Hi Blaise,

It would probably be easiest to run two search queries in a script. The first query would get the list of inactive managers, and the second query would get the employees of each inactive manager. You can use the [search API](https://developer.sailpoint.com/idn/api/v3/search) in a script to automate this. To get the list of inactive managers, use this body:

```json
{
    "indices": [
        "identities"
    ],
    "query": {
        "query": "isManager:true AND inactive:true"
    }
}

```

Then, construct one big query with all the inactive managers, or loop over each manager to get the identities. For examle:

```json
{
    "indices": [
        "identities"
    ],
    "query": {
        "query": "manager.id:<managerId>"
    }
}

```

---

<div class="post-metadata">

**Author:** ![bostelmann](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bostelmann](https://developer.sailpoint.com/discuss/u/bostelmann)\
**Post date:** [August 19, 2022, 2:29pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/3 "2022-08-19T14:29:36Z")

</div>

Thanks @colin_mckibben, I thought about this as well and it was going to be my fall back plan if no one replied to the thread.

I was hoping to learn a bit more about Elasticsearch and its implementation in IdentityNow.

To confirm, is this request just not possible in IdentityNow or to difficult to solution to the point the script is the easier approach?

Note, the intention would be ultimately turn this into a policy for HR so that we can help them keep their data clean.

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [August 19, 2022, 2:50pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/4 "2022-08-19T14:50:42Z")

</div>

Admittedly, I don’t have enough experience in elastic search to determine if this is possible or not with a single query.

---

<div class="post-metadata">

**Author:** ![bostelmann](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bostelmann](https://developer.sailpoint.com/discuss/u/bostelmann)\
**Post date:** [August 19, 2022, 3:10pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/5 "2022-08-19T15:10:15Z")

</div>

No worries @colin_mckibben, thanks for the reply. Hopefully some other IDN developers can shed some light.

---

<div class="post-metadata">

**Author:** ![cpatel](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@cpatel](https://developer.sailpoint.com/discuss/u/cpatel)\
**Post date:** [August 22, 2022, 5:48am UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/6 "2022-08-22T05:48:32Z")

</div>

You can have identity attribute on each identity level which shows LCS of manager and then use that attribute directly in search to find out those identities.

Use this to build that transform: [IdentityNow Transforms - Get Reference Identity Attribute - Compass](https://community.sailpoint.com/t5/IdentityNow-Wiki/IdentityNow-Transforms-Get-Reference-Identity-Attribute/ta-p/180554)

---

<div class="post-metadata">

**Author:** ![bostelmann](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bostelmann](https://developer.sailpoint.com/discuss/u/bostelmann)\
**Post date:** [August 22, 2022, 1:01pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/7 "2022-08-22T13:01:44Z")

</div>

Thank you for the idea @cpatel! It would definitely be a simple solution that would support policies.

It is unfortunate that IdentityNow does not appear to support nested queries. Would love to get some further insight from the development team at SailPoint to determine if this is a product limitation or just a lack of documentation.

Making a new Identity Profile attribute any time we want to do a search on a different manager attribute does not seem very efficient. ☹

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [August 22, 2022, 6:13pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/8 "2022-08-22T18:13:19Z")

</div>

Hey Blaise, we would love to hear this feedback on our [ideas portal](https://ideas.sailpoint.com/), which is monitored by our product team.

---

<div class="post-metadata">

**Author:** ![bostelmann](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bostelmann](https://developer.sailpoint.com/discuss/u/bostelmann)\
**Post date:** [August 22, 2022, 7:19pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/9 "2022-08-22T19:19:23Z")

</div>

@colin_mckibben, I have no issues submitting this to the idea portal, but do we know for certain if this is a limitation in IdentityNow or just a knowledge gap in everyone’s understanding? Or do I submit an idea for the development team to tell me if this can already be done or not?

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [August 22, 2022, 9:17pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/10 "2022-08-22T21:17:25Z")

</div>

FYI I would use the updated docs on this transform operation here: [IdentityNow Transforms - Get Reference Identity Attribute](https://developer.sailpoint.com/idn/docs/transforms/operations/get-reference-identity-attribute).

---

<div class="post-metadata">

**Author:** ![bostelmann](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bostelmann](https://developer.sailpoint.com/discuss/u/bostelmann)\
**Post date:** [August 22, 2022, 11:41pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/11 "2022-08-22T23:41:13Z")

</div>

Thanks @colin_mckibben, I suppose this tip is for perusing @cpatel recommended solution?

I don’t believe you can reference transforms within searches?

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [August 22, 2022, 11:45pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/12 "2022-08-22T23:45:03Z")

</div>

I will let Colin or Chirag answer for posterity and making sure you get the most accurate answer. I just saw the docs link Chirag posted was out of date and wanted to make sure you at least had the latest one 😛

---

<div class="post-metadata">

**Author:** ![bostelmann](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bostelmann](https://developer.sailpoint.com/discuss/u/bostelmann)\
**Post date:** [August 22, 2022, 11:58pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/13 "2022-08-22T23:58:16Z")

</div>

Ah, thank you for the heads up. It helped as I had no idea the documents on compass were moved to the developer site and not being maintained anymore.

If that is the case then you might want to add a disclaimer at the top of the relevant articles in compass.

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [August 23, 2022, 12:01am UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/14 "2022-08-23T00:01:38Z")

</div>

We’re slowly working on that one!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [July 19, 2023, 2:23pm UTC](https://developer.sailpoint.com/discuss/t/nested-query-on-managers/5435/15 "2023-07-19T14:23:27Z")

</div>

Closed on July 19, 2023, 2:23pm UTC


