You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.