Splunk® SOAR (Cloud)

Build Playbooks with the Playbook Editor

The classic playbook editor will be deprecated soon. Convert your classic playbooks to modern mode.
After the future removal of the classic playbook editor, your existing classic playbooks will continue to run, However, you will no longer be able to visualize or modify existing classic playbooks.
For details, see:

Add custom fields to your playbook

You can define and use your own custom fields for events — either globally or for specific event types — in a playbook. For example, you might add a custom field named Department and assign it a list of values for each department in your organization (for example, IT Ops, Sales, and Business).

Using custom fields in playbooks requires special coding.

Plan your naming convention carefully. Custom field names described here require additional special handling:

  • names containing characters other than letters, numbers, or underscores (_)
  • names starting with a space


Update and read custom field values

To update custom field values in containers, use the following code examples with the container.update API :

Update a custom field value

Example code to update a custom field value from a container.

    outputs = {}
    
    # Write your custom code here...
    container = {"id": container_id}
    update = {
        "custom_fields": {
            field_name: field_value,
        },
    }

    # Make the HTTP request
    success, message = phantom.update(container, update)
    
    assert success, message
    
    # Return a JSON-serializable object
    assert json.dumps(outputs)  # Will raise an exception if the :outputs: object is not JSON-serializable
    return outputs


Read a custom field value

While not technically an update function, reading a custom field value also uses the container.update API.

Example code to read (get) a custom field value from a container.

   outputs = {}
    
    # Write your custom code here...
    container = phantom.get_container(container_id)
    custom_fields = container.get("custom_fields", {})
    outputs["field_found"] = field_name in custom_fields
    outputs["field_value"] = custom_fields.get(field_name)
    
    # Return a JSON-serializable object
    assert json.dumps(outputs)  # Will raise an exception if the :outputs: object is not JSON-serializable
    return outputs
Last modified on 29 May, 2024
Save a playbook so can access it   Use keyboard shortcuts in the playbook editor

This documentation applies to the following versions of Splunk® SOAR (Cloud): current, current


Was this topic useful?







You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters