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

How to add user properties in Confluence?

JIRA-Support ZKB May 10, 2022

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

0 votes
JIRA-Support ZKB November 29, 2022

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
AUG Leaders

Atlassian Community Events