CherwellCreateIncident

This script is an example script of how to create an incident in Cherwell. The script wraps the create business object command in the cherwell integration. When writing your own script to create a business object, follow the instructions in the configuration part, but do not change the execution section.

python · Cherwell

Source

import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *

args = demisto.args()

# ####################################################################################
# ############################## CONFIGURATION PART ##################################
# ####################################################################################

"""
 `BUSINESS_OBJECT_TYPE` is the name of business object you wish to create using this script.
 In this case we set it to be 'incident' as this script is in charge of creating incidents.
"""

BUSINESS_OBJECT_TYPE = "Incident"

"""
 `FIELDS` contains all the fields you wish to include in your business object.
 In order to add a field to a business object you will need to have a corresponding argument in the script arguments.
 After you added the argument to the script arguments you will need to add its value to the `FIELDS` object by using
 `args.get('argument_name').
 Make sure the key is identical to the field name in the Cherwell system.

 For example: we wished to create an incident with a requesting customer field in it, thus, we added a
 customer_display_name argument to this script, we pulled the value of the argument by using
 `args.get('customer_display_name')` and we set the key name to be `CustomerDisplayName` - as it appears in the Cherwell
 system.

 Expert tip: if you don't want to keep Demisto's arguments naming convention, you can name your arguments exactly as
 they appear in the Cherwell system, this will shorten the `FIELDS` constant to be `FIELDS = args`
"""
FIELDS = {
    "Description": args.get("description"),
    "Priority": args.get("priority"),
    "CustomerDisplayName": args.get("customer_display_name"),
    "OwnedBy": args.get("owned_by"),
    "Service": args.get("service"),
    "CallSource": "Event",
}


# ####################################################################################
# ############################## EXECUTION PART ######################################
# ####################################################################################


def build_arguments():
    arguments = {
        "type": BUSINESS_OBJECT_TYPE,
        # As `owned_by` and `service` arguments are not mandatory we make sure to remove them by using the createContext
        # function with removeNull flag set to true.
        # If all arguments are mandatory it would be sufficient to use `json: FIELDS`
        "json": createContext(FIELDS, removeNull=True),
    }
    return arguments


result = demisto.executeCommand("cherwell-create-business-object", build_arguments())
demisto.results(result)

README

This script is an example script of how to create an incident in Cherwell. The script wraps the create business object command in the cherwell integration. When writing your own script to create a business object, follow the instructions in the configuration part, but do not change the execution section.

Script Data


Name Description
Script Type python3
Tags Cherwell
Cortex XSOAR Version 5.0.0

Dependencies


This script uses the following commands and scripts.

  • cherwell-create-business-object

Inputs


Argument Name Description
description Incident description.
priority Incident priority.
owned_by Incident owner.
service Service needed.
customer_display_name Requesting customer name.

Outputs


Path Description Type
Cherwell.BusinessObjects.PublicId Incident public ID String
Cherwell.BusinessObjects.RecordId Incident record ID String