There is a scenario where i need to copy comments from one page to another when i copy the page. Adaptavist suggested to use scriptrunner plugin for confluence. Can anybody suggest the script to copy the comments. Also i cannot find the event Pagecopy in the scriptrunner event triggers.
Hi Sujatha,
You can use the following script in Script Console. You just need to change the id of the pages you are referring to.
Here's how you can get the page id.
import com.atlassian.confluence.pages.Page import com.atlassian.confluence.pages.Comment import com.atlassian.confluence.pages.PageManager import com.atlassian.sal.api.component.ComponentLocator import com.atlassian.confluence.core.DefaultSaveContext def pageManager = ComponentLocator.getComponent(PageManager) Page initialPage = pageManager.getPage(98311) Page targetPage = pageManager.getPage(98305) for (Comment comment : initialPage.getComments()) { targetPage.addComment(comment) } pageManager.saveContentEntity(targetPage, DefaultSaveContext.MINOR_EDIT)
Regards,
Katy
Adaptavist Product Support
Hi Kelly,
This is a more generic requirement and not specific to a page. Every time i copy a page it should copy the comments.
I want to bind this to the pagecopy event actually, but i cannot find the event trigger to copy page event in the scriptrunner plugin, however i can find oher triggers like pagecreate, pagemove pageupdated etc.
Regards
Sujatha
If you use the ScriptEventHandlers you'll find the PageCopyEvent. With this event you can get the destination and origin.
Did you try this?
Rafael
Yes i have tried this and I could not find the PageCopy event. That is when i reached out.
It looks like you're new here. Sign in or register to get started.