How to sync change history to the text custom field

    This article shows how to sync change history field values from the Jira cloud or Jira on-premise to a Jira cloud text custom field.

    Exalate allows syncing change history between Jira On-premise instances, or sending over the change history info from the Jira Cloud instance. Since there is no option to update change history on the Jira cloud instance, you can sync change history into a text custom field. In this case, the change history will be updated on both sides.

    Use the following scripts to sync change history to the text custom field:

    Source side

    JIRA SERVER JIRA CLOUD

    Add the code below to the Outgoing sync rules:

     replica.changeHistory = issue.changeHistory

    Destination side

    JIRA CLOUD

    Add the code to the Incoming sync rules to add the change history information into the text custom field.

    Please replace the "Text Field" with your custom field name in the code below.

    def historyToListOfStrings(history){
        def format = new java.text.SimpleDateFormat("yyyy-MM-dd")
        def date = format.format(history.created)
        history.changeItems.collect { i ->
            "|${history.author.displayName}|${date}|${i.field}|${i.fromValue}|${i.toValue}|"
        }
    }
    issue.customFields."Text Field".value = "||Author||Date||Field||From||To||\n"+String.join("\n",replica.changeHistory.reverse().inject([]){ result, history -> result += historyToListOfStrings(history); result })


    You will sync change history information into a text custom field in a table format:

    See also