I am trying to get a state from a slicer using getSlicerState but I am getting the error below:
TypeError: Cannot read property 'contract' of null
at e.getExploration (reportEmbed.slicer-api.min.js:1)
at e.tryGetVisualContainer (reportEmbed.slicer-api.min.js:1)
at e.<anonymous> (reportEmbed.slicer-api.min.js:1)
at reportEmbed.slicer-api.min.js:1
at Object.next (reportEmbed.slicer-api.min.js:1)
at reportEmbed.slicer-api.min.js:1
at new r (powerbiportal.dependencies.bundle.min.js:13)
at p (reportEmbed.slicer-api.min.js:1)
at e.handleSlicerRequest (reportEmbed.slicer-api.min.js:1)
at e.<anonymous> (reportEmbed.slicer-api.min.js:1)
This is my code:
this.report.getPages().then(pages => {
let pageActive = pages.filter(page => page.isActive)
if (pageActive[0]){
pageActive[0].getVisuals().then(function(visuals) {
console.log(visuals.filter(visual => visual.title === 'Basket'));
visual = visuals.filter(visual => visual.title === 'Basket');
visual[0].getSlicerState()
.then(state => {
console.log(state)
});
});
}
});
Does anyone know what this issue is?
visual[0] is a VisualDescriptor. It is supposed to work straightaway.
Thanks
Thanks!
6 Comments
- v-qiuyu-msftCommunity Support
- ankurmundhraNew Member
Were you able to resolve it? I get this error when different level hierarchies are selected.
- PiloosAdvocate I
Issue still seems to be present in powerbi-client 2.17.2
- ankurmundhraNew Member
Piloos - We also created an MS support ticket for that but the support team couldn't resolve it and they also do not have a timeline for when it will be fixed.
As a work around our Power BI team, seperated out each slicer. So instead of 1 heirarchy slicer, we created 4 non-heirarchy slicers. We filter the lower (heirarchy) slicers based on the parent slicer selection.
Let me know if you need any more details.
Thanks!
-Ankur
- PiloosAdvocate I
ankurmundhra thanks for the reply. It is a pity that Microsoft does not solve such basic very reproducible issues faster...