Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I am having an issue trying to use the applyPatches method to change the measure in a pivot table. I have been able to change the sort order and various other properties, but I assume there is a problem with the syntax of the JSON I am using:
var patches = [{
'qPath': '/layout/qHyperCubeDef/qMeasures/0',
'qOp': 'replace',
'qValue': '{\'qDef\':\'Sum(Value)\'}'
}];
vis.applyPatches( patches, true );
The error I am getting is:
I have also tried without "layout" in the path, but I still get the error message. Depending on the qValue entry, I can also get a slightly different error message:
Any help would be gratefully received.
Richard
Hi Richard,
You're right there should be no '/layout' in your path, the path starts with '/qHyperCubeDef'. (You are actually not patching the layout but the properties structure). A good way to find to path is to use the /options/developer switch to inspect the objects properties. You will find something like this:
So the path will be '/qHyperCubeDef/qMeasures/0/qDef/qDef' (yes,there should be two qDef).
The value should be a string in a string, something like '"Sum(Value)"'. You could also use JSON.stringify, but that's more if you need a structure with several properties.
Hope this helps
Erik Wetterberg
Hi Richard,
You're right there should be no '/layout' in your path, the path starts with '/qHyperCubeDef'. (You are actually not patching the layout but the properties structure). A good way to find to path is to use the /options/developer switch to inspect the objects properties. You will find something like this:
So the path will be '/qHyperCubeDef/qMeasures/0/qDef/qDef' (yes,there should be two qDef).
The value should be a string in a string, something like '"Sum(Value)"'. You could also use JSON.stringify, but that's more if you need a structure with several properties.
Hope this helps
Erik Wetterberg
Excellent response as always Erik. Also, thanks for the /options/developer tip.
I was confusing the layout with the properties, as you say, and forgetting the second qDef. In the end, the following code works:
var strMeasure= '"Sum(Value)"';
var patches = [{
'qPath': '/qHyperCubeDef/qMeasures/0/qDef/qDef',
"qOp": "replace",
'qValue': strMeasure
}];
vis.applyPatches( patches, true );
One more thing Erik. Is it possible to apply more than one change, e.g. change measures and chart title in the same call to applyPatches? If so, what would the syntax look like?
Sure, that's why it's an array. Just add some more patches to the array, the same syntax(qPath, qOp, qValue) for all of them. You can also use objects, if you for example want to change the sort order or something. In that case JSON.stringify is your friend.
Erik Wetterberg
Thanks again Erik.
Hello!
I need to use applyPatches method to change some dimension property in a pivot table.
Does anyone have a properties.js file to do that?
Thanks!