Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,457,736
Community Members
 
Community Events
176
Community Groups

How to add user properties in Confluence?

Hi there

I am new with Confluence ScriptRunner, and I'm a bit lost. I have to create a screen, when a user connects to Confluence, where he has to accept the Conditions of use. 

I want to save the agreement as a user property, so I can later check who agreed and who didn't.

I couldn't find anything in Confluence about adding new properties/settings to the user.

Is there a way ? Did anybody do that ?

Thank you for your attention !

Pascal

1 answer

So if some people are still interessted, the best solution is to use Bandana, that work with a context (could be global, a space key or a specific context for the properties you manage), a key (for me a string with the context name + user key + property version) and the value you want to store.

See Persistence in Confluence (atlassian.com) and What is Bandana? One form of Confluence persistence (atlassian.com)

 

Simple code: 

import com.atlassian.bandana.BandanaManager
import com.atlassian.bandana.BandanaContext
import com.atlassian.confluence.setup.bandana.ConfluenceBandanaContext

String myContext = "<your context name>"
String myKey = "<your key>"
def myValue ="This could be text or a structure, an object ..."

ConfluenceBandanaContext ctx = new ConfluenceBandanaContext(myContext)
def bandanaManager = ComponentLocator.getomponent(BandanaManager)

// Store the value
bandanaManager.setValue(ctx, myKey, myValue);

//Retrieve the value
def myNewValue = bandanaManager.getValue(ctx, myKey) 
Ok, now I'm fighting because I created a class to structure my data.
When I store data in bandana (setValue), it works (data are in the DB), but I can't retrieve them anymore (with getValue).
I have a warning when I store the data:
Non-serializable type groovy.util.myClass is not compatible with remote Bandana cache

but the data are anyway in the DB !

I don't get it ...

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events