I use 'Label Add Event', and I need to get the page id.
How can I do it in 'event listeners'?
I have Confluence version 6.13.8
Tnx,
Daniel
Hi Daniel!
You can get the Id of the page the label is being added to by first getting the Labellable object from the Label event and then casting it as a Page. The page Id can then be retrieved from with the getContentId() method.
I've added a code snippet below that shows this in action!
import com.atlassian.confluence.pages.Page
def page = event.getLabelled() as Page
log.warn page.getContentId()
I hope this helps!
Thanks,
Lee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
As you're listening for multiple events you will need to cast the provided event to the particular event you wish to take action on.
So, in this case, you will need to do the following:
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.event.events.label.LabelAddEvent
def labelEvent = event as LabelAddEvent
def page = labelEvent.getLabelled() as Page
log.warn page.getContentId()
I'd also recommend separating the events you are listening for into individual listeners as this will make them simpler to implement and maintain your code.
Thanks,
Lee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, It worked and I caugth the event and the page id!
Bug now I am handeling with a different problem with this script:
Can you help me with it please?
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.