Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm new to extension and Javascript in general. Have started poking around and experimenting with extensions.
I am wondering if it's possible to retrieve the expression of a measure and change it.
And if it's possible how, where and when should you do it.
Best regards
Karl
Hi Karl,
You could check out this thread.
When you do getProperties() in an extension with a qHyperCubeDef you will get a structure thats described here. The measure will be in qMeasures[index].qDef. Modify it and call setProperties:
var me = this;
this.backendApi.getProperties().then(function(reply){
reply.qHyperCubeDef.qMeasures[0].qDef.qDef = '1+1'; //your new expression
me.backendApi.setProperties(reply);
});
Note that both setProperties and getProperties are asynchronous calls.
Erik
edit: added the trailing );
edit2: added another qDef..
All measures informations come in : layout.qHyperCube.qMeasureInfo
The Backend API GetMeasureInfos will also return measures informations.
Modifying an expression syntax will require use of Mashup API, a good starting point is the createCube method :
Hi Karl,
You could check out this thread.
When you do getProperties() in an extension with a qHyperCubeDef you will get a structure thats described here. The measure will be in qMeasures[index].qDef. Modify it and call setProperties:
var me = this;
this.backendApi.getProperties().then(function(reply){
reply.qHyperCubeDef.qMeasures[0].qDef.qDef = '1+1'; //your new expression
me.backendApi.setProperties(reply);
});
Note that both setProperties and getProperties are asynchronous calls.
Erik
edit: added the trailing );
edit2: added another qDef..
Thanks Erik!
There where a type-o in your answer code, so for future readers could you add ); to the end of the codesnippet?
OK, fixed. Thanks for pointing that out.
/Erik
Found one more thing, there where a qDef missing also. Got a JSON Parse error
I have one more question, is there a notification when the properties in a hypercube changes?
What I am trying to do is add a set analsysis to a measure and only wan't to do that once every time the user changes/adds a measure.
You will get a change notification in the form of a call to the paint method on all invalidations of the object. changing properties are one action that will invalidate for you. reload of data and change of related selections are other.
My Javascript knowledge is very limited. I don't understand what you mean, could you explain with a code snippet?
define( [
],
function ( ) {
return {
paint: function () {
// This segment will be called every time
// the visualization needs to handle the
// change induced by an invalidation
}
};
} );