import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 # Variable initialization: html = "" campaign_incidents = "" try: # Getting incident context: incident_id = demisto.incidents()[0].get("id", {}) context = demisto.executeCommand("getContext", {"id": incident_id}) campaign_incidents = context[0]["Contents"].get("context", {}).get("EmailCampaign", {}).get("incidents", {}) html = ( f"
" f"Number of Incidents
{len(campaign_incidents)}
" ) except Exception: html = "
No Campaign
" # Return the data to the layout: demisto.results({"ContentsFormat": EntryFormat.HTML, "Type": EntryType.NOTE, "Contents": html})