Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
rbecher
Not applicable

Backend Api getProperties / setProperties

Hi,

I'm looking for examples how to use this.backendApi.getProperties() / setProperties() methods. Anything on this?

- Ralf

1 Solution

Accepted Solutions
erik_wetterberg
Not applicable

Re: Re: Backend Api getProperties / setProperties

I'm afraid this doesn't work. The getPropertries is asynchronous, and does not return properties, but a promise.

It's a bit more complicated, but you can do something like this:

var me = this;

this.backendApi.getProperties().then(function(reply){

        reply.title = 'New title';

        me.backendApi.setProperties(reply);

});

Erik Wetterberg
https://extendingqlik.upper88.com/
16 Replies
Not applicable

Re: Backend Api getProperties / setProperties

You can find all the relevant documentation on the Qlik Sense help site http://help.qlik.com or for this specific question look here https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/Workbench/Content/BuildingExten...

rbecher
Not applicable

Re: Backend Api getProperties / setProperties

But there is no example for getProperties / setProperties..

Not applicable

Re: Backend Api getProperties / setProperties

Use

myprops = this.backendApi.getProperties();

this.backendApi.setProperties(myprops);

rbecher
Not applicable

Re: Backend Api getProperties / setProperties

Thanks, this was clear so far. But how access/set a property in myprops?

swr
Not applicable

Re: Backend Api getProperties / setProperties

rbecher
Not applicable

Re: Backend Api getProperties / setProperties

Hi Stefan,

but this is not for this.backendApi.getProperties() ?

Best regards,

Ralf

Not applicable

Re: Backend Api getProperties / setProperties

Actually its very similar, the structure you retrieve is the qProp structure in the json response for getProperties, and the first item in the params array for setProperties

The only difference is that the javascript methods in backendAPI strips away the rest.

But I agree with you the Examples are missing and should be added. I'll file a request for it.

erik_wetterberg
Not applicable

Re: Re: Backend Api getProperties / setProperties

I'm afraid this doesn't work. The getPropertries is asynchronous, and does not return properties, but a promise.

It's a bit more complicated, but you can do something like this:

var me = this;

this.backendApi.getProperties().then(function(reply){

        reply.title = 'New title';

        me.backendApi.setProperties(reply);

});

Erik Wetterberg
https://extendingqlik.upper88.com/
erik_wetterberg
Not applicable

Re: Re: Re: Backend Api getProperties / setProperties

Another option would be to use the applyPatches method. This allows you to change properties without fetching them first (getProperties is not needed)

self.backendApi.applyPatches([{

                        "qPath" : "/title",

                        "qOp" : "replace",

                        "qValue" : "\"New title\""

                    }], true);

                   

The last parameter is th softpatch flag: if you set it to true, the change will be regarded as temporary and not persisted.

Note the format of the qValue parameter: this is actually a JSON value inside a string (since you can patch strings, numbers or JSON objects). In this case we want to set a string value, and so we need double citation marks. If we wanted to set a number (not valid in the title) it should be something like "qValue": "-1".

Erik Wetterberg
https://extendingqlik.upper88.com/