JiraV3ConvertSubtasksToTable

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

python · Atlassian Jira

Details

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

README

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

Script Data


Name Description
Script Type python3
Tags dynamic-section
Cortex XSOAR Version 5.5.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 subtasks 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", "jirasubtask"],
            {},
        ):
            return_results(convert_to_table(context))
        else:
            return CommandResults(readable_output="No data to present")

    except Exception as e:
        demisto.error(traceback.format_exc())  # print the traceback
        return_error(str(e))


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