JiraV3ConvertCommentsToTable

This script is used to convert Jira comments to a table.

python · Atlassian Jira

Details

IDJiraV3ConvertCommentsToTable
Languagepython
From Version6.8.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagsdynamic-section

README

This script is used to convert Jira comments to a table.

Script Data


Name Description
Script Type python3
Tags dynamic-section
Cortex XSOAR Version 6.8.0

Inputs


There are no inputs for this script.

Outputs


There are no outputs for this script.

from itertools import chain

import demistomock as demisto
from CommonServerPython import *


def convert_to_table(context_results: str) -> CommandResults:
    """
    Args:
        context_results (str): String representing a list of comment entries.

    Returns:
        CommandResults: CommandResults object containing only readable_output
    """

    comment_entries = list(json.loads(context_results))

    md = tableToMarkdown(
        "",
        comment_entries,
        headers=[*dict.fromkeys(chain.from_iterable(comment_entries))],
        removeNull=True,
        sort_headers=False,
        headerTransform=pascalToSpace,
    )

    return CommandResults(readable_output=md)


def main():  # pragma: no cover
    try:
        if context := dict_safe_get(
            demisto.callingContext,
            ["context", "Incidents", 0, "CustomFields", "jiracomment"],
            {},
        ):
            return_results(convert_to_table(context))
        else:
            return CommandResults(readable_output="No data to present")

    except Exception as exc:
        return_error(f"Failed to execute JiraV3ConvertCommentsToTable. Error: {exc}")


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()