Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This script will add a new label to all of the child pages of the selected parent pageremove an old label from a page and replace it with a new one.

Code Block
languagejava
linenumberstrue
number [] issuesstring oldLabel = selectPages("stateexpiry < startOfDay()")"old_label";
string newLabel = "new_label";


//newget labelsall topages bewith addedthe toold pageslabel
stringnumber [] newLabels = "confluence|power_scripts"pages = selectPages("label = \"" + oldLabel + "\"");

//get the id of the parent
number parent = getPage("CTR", "Add a new label to the children of a page");

//get the ids of the children
number [] children = getChildPages(parent);

for(number child in children) { //loop through children
loop through each page
for(number page in pages) {
   
   //get the pages labels
   string [] lbls = %page%.labels;
   //remove the old label from the labels list
   lbls = arrayDeleteElement(lbls, oldLabel);
   //add new label to the list
   lbls += newLabel;
   //addset the labels tofor the child page
    addLabelssetLabels(childpage, newLabelslbls);
}

See Other Recipes

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
cqllabel = "pages"

...