How to Sync Rich Text and HTML Between Asana and Other Systems

    How to Sync Rich Text and HTML Between Asana and Other Systems

    When syncing data between Asana and other systems like Jira, GitHub, or Azure DevOps, it's important to manage rich text formatting to ensure content maintains its appearance across different platforms.

    Rich Text in Asana: Asana supports HTML formatting for descriptions and comments. When syncing with other systems, you can preserve formatting or convert to plain text.

    Option 1: Sync as plain text

    If you don't need to preserve rich text formatting, strip HTML before syncing:

    Asana Outgoing Sync

    replica.description = nodeHelper.stripHtml(entity.description)
    replica.comments = nodeHelper.stripHtmlFromComments(entity.comments)

    Asana Incoming Sync

    entity.description = replica.description
    entity.comments = commentHelper.mergeComments(entity, replica)

    Option 2: Preserve HTML formatting

    For systems that support HTML (like Azure DevOps), preserve the formatting:

    Asana Outgoing Sync

    replica.description = nodeHelper.convertAsanaHtmlToExternalHtml(entity.description)
    replica.comments = entity.comments.collect { comment ->
        comment.body = nodeHelper.convertAsanaHtmlToExternalHtml(comment.body)
        return comment
    }

    Asana Incoming Sync

    entity.description = nodeHelper.convertToAsanaHtml(replica.description, true)
    entity.comments = commentHelper.mergeComments(entity, replica, {
        comment ->
            comment.body = nodeHelper.convertToAsanaHtml(comment.body)
            comment
    })

    Option 3: Convert between HTML and Markdown

    For systems like Jira that use Markdown, use conversion helpers:

    Jira to Asana

    // Jira Outgoing Sync
    replica.description = nodeHelper.getHtmlField(issue, "description")
    replica.comments = nodeHelper.getHtmlComments(issue)
    
    // Asana Incoming Sync
    entity.description = nodeHelper.convertToAsanaHtml(replica.description, true)
    entity.comments = commentHelper.mergeComments(entity, replica, {
        comment ->
            comment.body = nodeHelper.convertToAsanaHtml(comment.body)
            comment
    })

    Asana to Jira

    // Asana Outgoing Sync
    replica.description = nodeHelper.convertAsanaHtmlToExternalHtml(entity.description)
    replica.comments = entity.comments.collect { comment ->
        comment.body = nodeHelper.convertAsanaHtmlToExternalHtml(comment.body)
        return comment
    }
    
    // Jira Incoming Sync
    issue.description = nodeHelper.toMarkDownFromHtml(replica.description)
    issue.comments = nodeHelper.toMarkDownComments(commentHelper.mergeComments(issue, replica))

    More information

    Have more questions? Ask the community