Markdown and Rich Text Support in Custom Fields

Originally asked by Harold Oconitrillo on 12 August 2022 (original question)


I want to show the replica issue status with a color. I can fetch replica.status.statusCategory.colorName, which is for example “yellow” but I have no idea how to convert that into a rich text field in Jira Cloud using Markdown.

Do you have an example how to properly make a text a specific supported color in the description field?

status.statusCategory.colorName is not even posted I see…

In the Jira API it does show up;

status": {
"self": "https://transdev-test.atlassian.net/rest/api/3/status/10016",
"description": "This was auto-generated by Jira Service Management during workflow import",
"iconUrl": "https://transdev-test.atlassian.net/images/icons/status_generic.gif",
"name": "Work in progress",
"id": "10016",
"statusCategory": {
"self": "https://transdev-test.atlassian.net/rest/api/3/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
issue.customFields. “Remote Issue URL” .value = remoteIssueUrl
issue.customFields. “remote Issue Status” = nodeHelper. toMarkDownFromHtml(“<font color=‘yellow’>is this yellow?</font>”)

issue.customFields. “Remote Issue Status”.value = “

issue.customFields.”Remote Issue URL.value = issueUrl
issue.customFields.”Remote Status Text .value = nodeHelper. toMarkDownFromHtml(“<font color=‘yellow’>is this yellow?</font>

Comments:

Harold Oconitrillo commented on 12 August 2022

Hi,

Can you please try as below?

if (replica.status){
    issue.description  = "{color:${replica.status.statusCategory.colorName}} ${replica.status.name} {color}"
} 

What is inside ${replica.status.name} representing the actual text can be replaced by description to do something like:

if (replica.status && replica.description){
    issue.description  = "{color:${replica.status.statusCategory.colorName}} ${replica.description} {color}"
} 

Feel free to contact us back for further questions.

Best regards,

Ariel Aguilar commented on 13 August 2022

Answer from client:

If you look at the payload, you’ll see that statusCategory.colorName is not present. It is part of the Jira issue API but not pushed over from Exalate I believe.

Secondly, you can easily replicate this behaviour of putting a status panel in your description on one end and you’ll see the “[ status name ]” on your target environment, instead of the status panel.

Ariel Aguilar commented on 13 August 2022

Also you can try to send the color from status while using a rest call, you can add the following into the Jira B - Outgoing sync:

 Map responseJson = new JiraClient(httpClient).http(
                    method = "GET",
                    path = "/rest/api/3/issue/${issueKey.id}",
                    queryParams = ["fields":["status"]],
                    body = null,
                    headers = [:]
            ) { response ->
        if (response.code >= 300 && response.code != 404) {
            throw new com.exalate.api.exception.IssueTrackerException("Failed to perform the request $method $path (status ${response.code}), and body was: \n\"$response.body\"\nPlease contact Exalate Support: ".toString() + response.body)
        }
        if (response.code == 404) {
            return null
        }
        def r = response.body as String
        def js = new groovy.json.JsonSlurper()
        def rJ = js.parseText(r)
        rJ
}
def statusColor = responseJson.fields?.status?.statusCategory?.colorName
replica.customKeys."color" = statusColor

Incoming Jira A:

issue.description  = "{color:${replica.customKeys."color"}} ${replica.status.name} {color}"

Kind regards,

Ariel

Patrick van der Rijst commented on 15 August 2022

Hi,

The status macro is actually now pushed as a status macro. I can’t show an example here but try the Jira status macro in a description and push that to your target.