GetAwayUsers
Returns a list of all the users marked as away in Cortex XSOAR.
- Type
- python
- Pack
- ShiftManagement
Source
from CommonServerPython import *
def main():
try:
users_command_response: Dict = demisto.executeCommand("getUsers", {})
if is_error(users_command_response) or not users_command_response:
raise DemistoException(f"Could not retrieve users\nError details: {get_error(users_command_response)}")
users_info: List[Dict] = users_command_response[0]["Contents"]
away_users = [user for user in users_info if user.get("isAway", False)]
outputs = [
{k: v for k, v in away_user.items() if k in ["id", "username", "email", "name", "phone", "roles"]}
for away_user in away_users
]
if outputs:
hr = tableToMarkdown("Away Users", outputs, headerTransform=string_to_table_header, removeNull=True)
else:
hr = "###Away Users\nNo team members were found away."
return_results(
{
"Type": entryTypes["note"],
"ContentsFormat": formats["markdown"],
"Contents": hr,
"EntryContext": {"AwayUsers": outputs} if outputs else {},
}
)
except Exception as e:
return_error(f"Failed to execute GetAwayUsers. Error: {e!s}")
""" ENTRY POINT """
if __name__ in ("__main__", "__builtin__", "builtins"):
main()
README
Returns a list of all the users marked as away in Cortex XSOAR
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | |
| Cortex XSOAR Version | 5.5.0 |
Inputs
There are no inputs for this script.
Outputs
| Path | Description | Type |
|---|---|---|
| AwayUsers.id | Away user ID. | String |
| AwayUsers.username | Away user username. | String |
| AwayUsers.name | Away user name. | String |
| AwayUsers.phone | Away user phone. | String |
| AwayUsers.roles | Away user roles. | Unknown |
| AwayUsers.email | Away user email. | Unknown |
Script Example
## Context Example
```json
{
"CortexXSOAR": {
"AwayUsers": {
"email": "admintest@demisto.com",
"id": "admin",
"name": "Admin Dude",
"phone": "+650-123456",
"roles": {
"demisto": [
"Administrator"
]
},
"username": "admin"
}
}
}
Human Readable Output
Away Users
Id Name Phone Roles Username admintest@demisto.com admin Admin Dude +650-123456 demisto: Administrator admin