AssignToNextShiftOOO
Randomly assigns the active incidents to on call analysts (requires shift management). This automation works with the other out-of-office automations to ensure only available analysts are assigned to the active incidents. This automation runs using the default Limited User role, unless you explicitly change the permissions. For more information, see the section about permissions here: For Cortex XSOAR 6 use the link https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/6.x/Cortex-XSOAR-Playbook-Design-Guide/Automations and for Cortex XSOAR 8 Cloud use the link https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/8/Cortex-XSOAR-Cloud-Documentation/Create-a-script.
python · Shift Management
Source
import random from CommonServerPython import * def main(): # check if we have any users on call to assign to users_on_call = demisto.executeCommand("getUsers", {"onCall": "true"}) if is_error(users_on_call): return_error(f"Failed to get users on call: {get_error(users_on_call)!s}") users_on_call = users_on_call[0]["Contents"] # if we don't have on shift users, return error, else reassign the provided incident id's to the on shift analysts if not users_on_call: return_error("No users on shift") list_name = demisto.getArg("listname") # get OOO users ooo_list = demisto.executeCommand("GetUsersOOO", {"listname": list_name}) if is_error(ooo_list): return_error(f"Failed to get users out of office: {get_error(ooo_list)!s}") list_info = ooo_list[0].get("EntryContext").get("ShiftManagment.OOOUsers") list_info = [i["username"] for i in list_info] # Get Away Users away_users_response = demisto.executeCommand("GetAwayUsers", {}) if is_error(away_users_response) or not away_users_response: return_error(f"Failed to get away users: {get_error(away_users_response)!s}") away_users: List[Dict] = away_users_response[0].get("EntryContext", {}).get("AwayUsers", []) away_user_names: List[str] = [away_user["username"] for away_user in away_users] if away_users else [] # Build list of available users non_OOO_list = [ x["username"] for x in users_on_call if x["username"] not in list_info and x["username"] not in away_user_names ] # Assign on call users to the Incidents, if there is anyone to assign if not non_OOO_list: return_error(message="No on call users to assign") else: incident_ids = argToList(demisto.args().get("incidentIds")) for incident_id in incident_ids: rand_user = random.choice(non_OOO_list) demisto.results(demisto.executeCommand("setIncident", {"id": str(incident_id), "owner": rand_user})) if __name__ in ("__builtin__", "builtins", "__main__"): main()
README
Randomly assigns the active incidents to on-call analysts (requires shift management). This automation works with the other out-of-office automations to ensure only available analysts are assigned to the active incidents.
Permissions
This automation runs using the default Limited User role, unless you explicitly change the permissions.
For more information, see the section about permissions here: For Cortex XSOAR 6, see the https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/6.x/Cortex-XSOAR-Playbook-Design-Guide/Automations for Cortex XSOAR 8 Cloud, see the https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/8/Cortex-XSOAR-Cloud-Documentation/Create-a-script for Cortex XSOAR 8 On-prem, see the https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/8.7/Cortex-XSOAR-On-prem-Documentation/Create-a-script.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | Shift Management, ooo |
| Cortex XSOAR Version | 5.0.0 |
Used In
This script is used in the following playbooks and scripts.
Assign Active Incidents to Next Shift V2
Inputs
| Argument Name | Description |
|---|---|
| incidentIds | A comma-separated list of active incident IDs to assign to the next shift, for example, 1,2,3,4. |
| listname | The name of the out-of-office list. Default is “OOO List”. |
Outputs
There are no outputs for this script.