PrintToParentIncident
Prints a value to the parent incident's war-room of the current alert.
python · Common Scripts
Details
| ID | PrintToParentIncident |
|---|---|
| Language | python |
| From Version | 8.7.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
README
Prints a value to the parent incident’s war-room of the current alert.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | |
| Cortex XSOAR Version | 8.7.0 |
Inputs
| Argument Name | Description |
|---|---|
| value | The value to print to the parent incident’s war-room. |
Outputs
There are no outputs for this script.
Script Example
!PrintToParentIncident value="Parent of 6 I assume?"
Context Example
{}
Human Readable Output
Successfully printed to parent incident INCIDENT-5.
import demistomock as demisto import pytest from CommonServerPython import DemistoException, EntryType from pytest_mock import MockerFixture def test_print_to_parent_incident(mocker: MockerFixture): """Tests print_to_parent_incident when the executeCommand command succeeds. Checks that the addEntries command is called with the right arguments. """ from PrintToParentIncident import print_to_parent_incident execute_command_mocker = mocker.patch.object( demisto, "executeCommand", return_value=[ { "Type": EntryType.NOTE, "Contents": "done", "HumanReadable": None, "EntryContext": None, } ], ) mocker.patch.object(demisto, "results") print_to_parent_incident( alert_id="4", value="Hello", parent_incident_id="INCIDENT-5", ) # Right command is called assert execute_command_mocker.call_args[0][0] == "addEntries" # Right arguments are given assert execute_command_mocker.call_args[0][1] == { "entries": '[{"Type": 1, "ContentsFormat": "markdown", "Contents": "Entry from alert #4:\\nHello"}]', "id": "INCIDENT-5", "reputationCalcAsync": True, } assert demisto.results.call_args[0][0]["HumanReadable"] == "Successfully printed to parent incident INCIDENT-5." def test_print_to_alert_error(mocker: MockerFixture): """Tests print_to_parent_incident when the executeCommand command fails. Checks that the system exists and an error message is returned. """ from PrintToParentIncident import print_to_parent_incident error_message = "Something went wrong" mocker.patch.object( demisto, "executeCommand", return_value=[ { "Type": EntryType.ERROR, "Contents": error_message, "HumanReadable": None, "EntryContext": None, } ], ) mocker.patch.object(demisto, "results") with pytest.raises(SystemExit): print_to_parent_incident( alert_id="4", value="Hello", parent_incident_id="INCIDENT-5", ) assert demisto.results.call_args[0][0] == { "Type": EntryType.ERROR, "ContentsFormat": "text", "Contents": error_message, "EntryContext": None, } def test_no_parent_incident_error(): """Check that we return an error when no parent incident is found""" from PrintToParentIncident import validate_parent_incident_id with pytest.raises(DemistoException): validate_parent_incident_id(parent_incident_id="", alert_id=4)