Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm looking for examples how to use this.backendApi.getProperties() / setProperties() methods. Anything on this?
- Ralf
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);
});
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...
But there is no example for getProperties / setProperties..
Use
myprops = this.backendApi.getProperties();
this.backendApi.setProperties(myprops);
Thanks, this was clear so far. But how access/set a property in myprops?
Hi Ralf,
here is one of the examples: https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/Qlik_Engine_API/Content/HowTos/...
Regards
Stefan
Hi Stefan,
but this is not for this.backendApi.getProperties() ?
Best regards,
Ralf
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.
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);
});
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".