How can I assign labels for child nodes (by SQL query)?

Hi,

I use a very strict labelling in our Confluence instance. I have a node with hundreds of child nodes. To create some new reports and filters (site has label xy or has not label yz queries) I need some new labels. (How) can I create a batch process for that (e.g. by SQL query)? Also interesting is to know, how can I do it the other way round?

Best regards

Stefan

2 answers

1 accepted

Hi Anselmo,

because many sites I neededto relabel used a live-template (Customware), I simply used a macro to do that. First, I removed all labels with a small user macro:

#set($currentlabels = $content.getLabels())
#foreach($label in $currentlabels)
#set($success = ${action.labelManager.removeLabel($content, $label)})
#end

After I removed everything from that pages, I removed the user macro. Then I put an add-label macro in my live-template:

{add-label:MYLABEL}

And sometimes a second one to get some Scaffolding data:

{add-label:%data:tools%}

That did it for me, maybe it is helpful for you as well. Have fun and good luck!

I see, what this kind of query by labels is good for and want to use the same. But I want to do it without SQL.

The best I can imagine is a LabelManager, which shows all used labels in a hierarchy an gives the opportunity to apply them on certain levels of the hierarchy (assigning it to all children at once optionally).

Also replacing different spelling of labels should be possible. On top an undo function might make the solution perfect.

It's a long time to Christmas from now. Let's see, what Santa will have for us.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,476 views 25 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you