Hi,
I wrote a script in event listeners that add to the title some text if a spesific label was added.
In the log of this script it look like the title was changed, but in the page itself the title stayed the same..
This is my script:
import com.atlassian.confluence.event.events.content.page.PageEvent
import com.atlassian.confluence.pages.Page
import com.atlassian.event.Event
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.event.events.label.LabelAddEvent
import com.atlassian.confluence.core.DefaultSaveContext
import com.atlassian.confluence.event.events.user.UserCreateEvent
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.user.ConfluenceUser
import com.atlassian.sal.api.component.ComponentLocator
import groovy.xml.MarkupBuilder
def labelEvent = event as LabelAddEvent
def page = labelEvent.getLabelled() as Page
log.warn page.getContentId()
def pageManager = ComponentLocator.getComponent(PageManager)
def space = page.getSpace();
log.warn space.getKey().toString();
if(space.getKey().toString()=='SPACE_NAME')
{
def pageLabels = page.getLabels()
def srs_lbl = 'srs'
if(pageLabels.toString().contains(srs_lbl)){
log.warn "with label SRS"
if(page.getTitle().startsWith('SRS-'))
{
log.warn "already has 'SRS-' in title"
return;
}
else
{
// add a prefix to the page's title
page.setTitle('SRS- ' + page.getTitle())
log.warn "add 'SRS-' to the title"
}
}
}
log.warn page.getTitle()
return
This is the log:
2020-04-22 06:11:33,276 WARN [runner.ScriptBindingsManager]: ContentId{id=343587177}
2020-04-22 06:11:33,278 WARN [runner.ScriptBindingsManager]: CNTRLM
2020-04-22 06:11:33,279 WARN [runner.ScriptBindingsManager]: with label SRS
2020-04-22 06:11:33,280 WARN [runner.ScriptBindingsManager]: add 'SRS-' to the title
2020-04-22 06:11:33,287 WARN [runner.ScriptBindingsManager]: SRS- Test please ignore
What's happening? Can someone help me with it? Maybe I need to reindex this page\Update it's values?
Daniel