Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
nitinsaivishnu1
Partner - Contributor II
Partner - Contributor II

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
mek
Employee
Employee

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"'
}

View solution in original post

5 Replies
ErikWetterberg

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')

nitinsaivishnu1
Partner - Contributor II
Partner - Contributor II
Author

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

 

ErikWetterberg

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

mek
Employee
Employee

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"'
}
nitinsaivishnu1
Partner - Contributor II
Partner - Contributor II
Author

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"'
}