Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

atlassian-connect-express 9: add your own settings to the database


In this article we will see how to add your own settings to the database.

This article is based on this one.

You can find the source code for the article here.

You can find a video for this article here.

Let’s say your application depends on some settings which are set by your application. Either you save it automatically or a user sets the settings in some of the pages of your application.

First of all, always consider to store the settings for your app in the Jira, Confluence or Bitbucket itself. On the date of writing this article it is not possible to store settings in Bitbucket itself. That is why we need to store settings in our database.

There are a couple of ways to do it. I will show you the simplest one.

When our app is installed the AddonSettings table is created:

Screenshot 2021-05-24 at 11.14.11.png

This table contains 4 fields: id, clientKey, key and val. By default atlassian-connect-express saves necessary to the framework data in rows where the key equals to clientInfo.

That is why to add your own settings you can add rows with your own key. Let’s say we call our key “appSettings”.

The val columns should be always a json.

Now let’s add our own row on app installation. We should change the code in backend/app.js:

addon.on('host_settings_saved', function(clientKey, data) {

to this one:

addon.on('host_settings_saved', function(clientKey, data) {
    addon.settings.set('appSettings', {settings1: "settings1 value"}, clientKey)
        .then(() => {
            addon.settings.get('appSettings', clientKey)
                .then((settings) => {

In this code we first create a new row with the appSettings key and then read it and log the result into console.

Now we need to delete the row if we uninstall our app. That is why let’s make the uninstalled endpoint look like this:'/uninstalled', addon.authenticate(), function (req, res) {
        addon.settings.del('appSettings', req.context.clientKey)
            .then(() => res.send(200))

We delete the row and then return the success status code.

Now let’s try to install our app again.

Here is the AddonSettings table:

Screenshot 2021-05-24 at 12.33.05.png

We can see that the row with the appSettings key was added.

Now let’s examine the logs and see if we can read the data from the row:

{ settings1: 'settings1 value' }

Yes, we are able to read the values.

Now let’s uninstall and see if the row was deleted:

Screenshot 2021-05-24 at 12.35.11.png

Yes, the row was deleted.

Everything works as expected. That is all for the article.

See you in the next article.

1 comment

Mohammed Amine Community Leader May 30, 2021

Great article @Alexey Matveev _Appfire_ you are really helping the community with this. Keep up the good work. 

Are you offering (or willing to offer) a training on Atlassian App dev? 


Log in or Sign up to comment
Community showcase
Published in Apps & Integrations

How we use Jira Service Management for our recruitment process! - Part 2

It is never about setting up a process and being done with it. Rather, the focus should always be on optimizing it for the best outcomes. Thus, we didn’t stop at setting up JSM for our recruitment pr...

187 views 0 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you