Skip to content

Conversation

@shivamvish160
Copy link
Contributor

Get User's Manager Chain

🧾 Overview

This ServiceNow Flow Action retrieves the full manager hierarchy for a given user. It returns a list of all managers above the user, including their name, email, title, and sys_id. This utility is ideal for approval workflows, escalation paths, and organizational reporting.

🚀 Purpose

  • Automate multi-level approval processes
  • Enable escalation logic based on reporting structure
  • Support org chart visualizations and audit trails

📥 Inputs

Name Type Description
userSysId String Sys ID of the user to look up

📤 Outputs

Name Type Description
managerChain Array List of manager objects with name, email, title
error String Error message if retrieval fails

🛠️ Usage Instructions

  1. Add this Flow Action to your Flow Designer.
  2. Provide the userSysId input (e.g., from a task or record).
  3. Use the managerChain output to drive approvals, notifications, or logs.

🧪 Example Output

[
  {
    "name": "Jane Doe",
    "email": "jane.doe@example.com",
    "title": "Director",
    "sys_id": "abc123"
  },
  {
    "name": "John Smith",
    "email": "john.smith@example.com",
    "title": "VP",
    "sys_id": "def456"
  }
]

@github-actions
Copy link

Valid PR for ActionPack

Thank you for your contribution. This PR complies with the CONTRIBUTING.md.
A maintainer will review this shortly. In the meantime, Happy Hacking!

@rohi-v rohi-v self-assigned this Oct 11, 2025
@rohi-v
Copy link
Contributor

rohi-v commented Oct 11, 2025

Hi @shivamvish160

Thank you for your contributions.
Here are my suggestions

  • Change the input from 'String' to 'Reference' because you are accepting only User SysID.
  • Worst case scenario - If user and manager are same then stop the loop or the code will go on continuous loop.

Keeping this PR Open, rest everything looks good.

Also added logic to prevent infinite loop if user is it's own manager
@shivamvish160
Copy link
Contributor Author

Hi @shivamvish160

Thank you for your contributions. Here are my suggestions

  • Change the input from 'String' to 'Reference' because you are accepting only User SysID.
  • Worst case scenario - If user and manager are same then stop the loop or the code will go on continuous loop.

Keeping this PR Open, rest everything looks good.

@rohi-v
Thanks for the feedback
I have added the required changes
kindly review

@rohi-v
Copy link
Contributor

rohi-v commented Oct 13, 2025

Looks Good, Thank You for the contribution

@rohi-v rohi-v merged commit 7d24858 into ServiceNowDevProgram:main Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants