PrintToAlert
Prints a value to the specified alert's war-room. The alert must be in status "Under Investigation".
- Type
- python
- Pack
- CommonScripts
Source
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
def print_to_alert_command(current_alert_id: str, value: str, alert_id: str, mark_as_note: bool = False) -> None:
"""Prints a value to the specified alert ID.
Args:
current_alert_id (str): The alert ID running the script.
value (str): The value to print.
alert_id (str): The alert ID to print to.
mark_as_note (bool): Whether to mark the printed war-room entry as a note.
"""
entry_note = json.dumps(
[
{
"Type": 1,
"ContentsFormat": EntryFormat.MARKDOWN,
"Contents": f"Entry from alert #{current_alert_id}:\n{value}",
"Note": mark_as_note,
}
]
)
entry_tags_res: list[dict[str, Any]] = demisto.executeCommand(
"addEntries", {"entries": entry_note, "id": alert_id, "reputationCalcAsync": True}
)
if isError(entry_tags_res[0]):
return_error(get_error(entry_tags_res))
else:
return_results(CommandResults(readable_output=f"Successfully printed to alert {alert_id}."))
def main(): # pragma: no cover
try:
current_alert: dict[str, Any] = demisto.incident()
current_alert_id: str = current_alert["id"]
args = demisto.args()
value: str = args["value"]
alert_id = args["alert_id"]
mark_as_note = argToBoolean(args.get("mark_as_note", False))
print_to_alert_command(current_alert_id=current_alert_id, value=value, alert_id=alert_id, mark_as_note=mark_as_note)
except Exception as ex:
return_error(f"Failed to execute PrintToAlert. Error: {ex!s}")
if __name__ in ("__main__", "__builtin__", "builtins"):
main()
README
Prints a value to the specified alert’s war-room. The alert must be in status “Under Investigation”.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Cortex XSOAR Version | 8.7.0 |
Inputs
| Argument Name | Description |
|---|---|
| value | The value to print to the war-room of specified alert. |
| alert_id | The alert ID to print to. |
| mark_as_note | Whether to mark the printed war-room entry as a note. |
Outputs
There are no outputs for this script.