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!
def page = event.getLabelled() as Page
I hope this helps!
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:
def labelEvent = event as LabelAddEvent
def page = labelEvent.getLabelled() as Page
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.
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?
Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...
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