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

Confluence Banner with ScriptRunner

Hi all

In this little article, I want to show you, how I made a Confluence Banner with ScriptRunner with some additional features.

My goal was a confluence banner, which:

  • can be closeable for every user and doesn't show up for this user again
  • is time controlled
  • has to show only for a few user groups.

Yes, I know there are plugins for this, but with 2000 licences, theese are very expensiv and I'm a curious developer. So I did this to find out, can I do this with scriptrunner. 

What I did was a confluence page, a script fragment, a REST Endpoint and a user macro. The confluence page is for the tracking which user has closed the banner.

Before I deep dive, I want to tell you, that this is a dirty way to fulfill my goal, but so far it works quite well.

Script fragment (also see github documentation)
This is the most important thing. I made a script fragment with a condition. In the condition, I made some settings for time, group and whether this user has already read the news banner.

  • pageId
    • On this page I save the users, which clicked on the close button. The informations will be stored in a TextProperty.
  • dateFrom / dateTo
  • groupname

The provider script has the banner and javascript for calling the REST Endpoint.

REST Endpoint (also see github documentation)
The REST Endpoint saves the user which clicked the close button on the created confluence page in the TextProperty

User Macro (also see github documentation)
The user macro reads all the users which are on this page in the TextProperty.

Result

When a user closes the banner, the user macro (in the confluence page) will generate the following table containing the user-data.

image.png

So I can track who clicked away the banner and when.

My versions

  • ScriptRunner: 6.10.0
  • Confluence: 7.4.1

All of the Scripts are in my new github project: https://github.com/laschi23/confluence-banner 

I am very grateful for all and any feedback :) 

Regards, Dominic

6 comments

Thomas Egger October 12, 2020

Hi Dominic,

sounds very interesting to me!

Where am I able to download the ZIP? I'm looking forward to give you some feedback then.

Cheers,
Thomas

Like # people like this
Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 12, 2020

Hi @Thomas Egger @Patrice Champet 

It seems that i can not upload a zip.
Therefore I uploaded the scripts to github.

https://github.com/laschi23/confluence-banner 

Joshua Yamdogo @ Adaptavist
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 15, 2020

Hi Dominic,

This is awesome! I managed to use your code to get this working in my instance:

Screen Shot 2020-10-15 at 1.54.53 PM.png

I will share this with the rest of the ScriptRunner for Confluence team. We absolutely love to see all the unique ways that people are utilizing our app.

Regards,

Josh

Software Engineer, ScriptRunner for Confluence

Thomas Egger October 15, 2020

Hi @Dominic Lagger,

I tested your script and it works perfectly.

  • Maybe you could improve the documentation so that it is clear for everybody which type of fragment (Custom web item, show a web panel, ...) to use and what to choose in the "Location" field.
  • It would also be helpful to state that the page id in the fragment is only for storage and is not responsible for showing the banner only on that page.
  • Have you already though of a version of your script for Jira?

Thanks a lot for sharing your work!

Cheers,
Thomas

Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2020

Hi @Thomas Egger 

Thank you very much for your feedback. 

On github, I changed the readme and also this article (reference to github). So it should be a little bit clearer. I also made some changes:

  • Change from StringProperty to TextProperty (StringProperty can only have 255 signs)
  • Add possibility for 3 groupnames, not only one

JIRA

I thought of a JIRA version, yes. But I didn't try it yet. But in my mind, this should be very easy. In JIRA you need the same fragment. The rest should be very similar, because closing the banner on JIRA could also call the REST Endpoint in Confluence. 

Regards, Dominic

Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2020

Hi Joshua Yamdogo @ Adaptavist 

Thanks a lot for this awesome feedback! I'm very happy that it worked on your system!

Thanks for sharing it with your team :) ! 

Regards, Dominic

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events