Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Unresolved in-line comments cql function Edited

Trying to create a custom cql function (using ScriptRunner) to return all unresolved comments, but everything with inline comments (be they unresolved or not) is showing up.

Any ideas?

import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.pages.Comment
import com.atlassian.confluence.pages.CommentManager


String spaceKey = params[0]


def ids = []

def spaceManager = ComponentLocator.getComponent(SpaceManager)
def pageManager = ComponentLocator.getComponent(PageManager)
def commentManager = ComponentLocator.getComponent(CommentManager)

Space space = spaceManager.getSpace(spaceKey)

    for (Page page : pageManager.getPages(space, true)) {
        List<Comment> allComments = commentManager.getPageComments(page.getId(), new Date(0))
        for (Comment comment in allComments) {
            if (comment.isInlineComment() && !comment.getStatus().isResolved()) {
                ids << String.valueOf(page.getId())
            }
        }
    }


return ids

1 answer

I got it working by the way, but having performance problems, because of all the loops... and it's not the prettiest. Any suggestions would be appreciated. I don't know how to get all pages with inline comments, without getting all pages with comments first, and then narrowing it down.

import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.pages.Comment
import com.atlassian.confluence.pages.CommentManager


String spaceKey = params[0]


def ids = []

def spaceManager = ComponentLocator.getComponent(SpaceManager)
def pageManager = ComponentLocator.getComponent(PageManager)
def commentManager = ComponentLocator.getComponent(CommentManager)

Space space = spaceManager.getSpace(spaceKey)

for (Page page : pageManager.getPages(space, true)) {
    for (Comment comment : commentManager.getPageComments(page.getId(), new Date(0))) {
        if (comment.isInlineComment() && comment.getStatus().isOpen()) {
            def parent = comment.getParent()
            if ((parent != null && parent.getStatus().isOpen())|| parent == null) {
                ids << String.valueOf(page.getId())
            }
        }
    }
}

return ids

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

Share your Confluence Cloud experience for a chance to win $500!

Take our 5-minute survey to win a $500 Visa gift card! Are you currently using Confluence Cloud? We want to hear from you! Fill out this quick survey about your Confluence Cloud experience so we ...

293 views 5 14
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you