Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Highlighted
Partner
Partner

Qlik Sense ApplyPatches API throwing Invalid Parameters

@dselgo_eidex 

@erik_wetterberg 

Can you help me on how to replace the dimension/measure of a bar or pie chart using ApplyPatches or SetOptions API..

I used the following mashup from the  https://github.com/erikwett/QonnectionsMashupby @erik_wetterberg 

 but it was throwing me invalid parameters.

The existing dimension is City and i'd like to change it to Country.

Is my qValue correct?

I have the following code

 

var patches = [{
'qPath': '/qHyperCubeDef/qDimensionInfo/0',
'qOp': 'replace',
'qValue': \"Country\"
}];


vis.applyPatches( patches, false );

 

Any help would be appreciated.

1 Solution

Accepted Solutions
Employee
Employee

Re: Qlik Sense ApplyPatches API throwing Invalid Parameters

Your path isn't quite right: use qDimensions instead of qDimensionInfo.

In addition, the content of qHyperCubeDef/qDimensions/0 is an NxDimension, so replacing that entire struct with a string is not valid, you need to replace the definition of the inline dimension:

{
  'qPath': '/qHyperCubeDef/qDimensions/0/qDef/qFieldDefs/0',
  'qOp': 'replace',
  'qValue': '"Country"'
}
5 Replies
erik_wetterberg
Honored Contributor

Re: Qlik Sense ApplyPatches API throwing Invalid Parameters

Hi,

You're right: your qValue is not correct. It should be a string in a string, so perhaps:

qValue: '"Country"'

 

or you can use JSON.stringify:

qValue: JSON.stringify('Country')

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

Re: Qlik Sense ApplyPatches API throwing Invalid Parameters

Hi Erik,

Thank you for the fast reply.

I tried changing it to both the values you suggested. It still throws me Invalid Parameters

Patch.png

 

erik_wetterberg
Honored Contributor

Re: Qlik Sense ApplyPatches API throwing Invalid Parameters

Hi,

I see now that the path is also wrong, applyPatch patches properties, qDimensionInfo is in the layout, it's called qDimensions in the properties.

https://help.qlik.com/en-US/sense-developer/April2018/APIs/EngineAPI/definitions-HyperCubeDef.html

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

Re: Qlik Sense ApplyPatches API throwing Invalid Parameters

Your path isn't quite right: use qDimensions instead of qDimensionInfo.

In addition, the content of qHyperCubeDef/qDimensions/0 is an NxDimension, so replacing that entire struct with a string is not valid, you need to replace the definition of the inline dimension:

{
  'qPath': '/qHyperCubeDef/qDimensions/0/qDef/qFieldDefs/0',
  'qOp': 'replace',
  'qValue': '"Country"'
}
Partner
Partner

Re: Qlik Sense ApplyPatches API throwing Invalid Parameters

Hi  @mek 

 

Thank you. It worked like a charm 😄

Can you also help me with changing the chart type as well ? Let's say a bar chart to pie chart? 

Pardon me for not knowing the qPath  correctly.

Will this work? 

{
'qPath': '/qInfo/qType',
'qOp': 'replace',
'qValue': '"piechart"'
}