Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Nojustice
Advocate I
Advocate I

getSlicerState on Inactive Pages

Hello All,

 

We are currently trying to implement functionality where we save the state of all slicers on a report so that when a user comes back to the report in the future, it re-renders in the state that the user left the report in.

 

We are however experiencing an issues whereby getSlicerState seems to error if retrieving slicerstates from any other page other than the active one. 

See example below:-

const pages = await report.getPages();
for (const page of pages) {
   let theSlicers;
   let allOfTheVisuals;
   await page
        .getVisuals()
        .then((visuals) => {
          allOfTheVisuals = visuals;
        })
        .catch((err) => {
          console.log(`error getting the page visuals:`, err);
        });
   // Separate out the slicers from the visuals
   theSlicers = allOfTheVisuals.filter((visual) => {
          return visual.type == "slicer";
        });
   const slicerFilterData = [];
      for (const slicer of theSlicers) {
        await slicer
          .getSlicerState()
          .then((filters) => {
            // If there are no filters then don't add the slicer.
            if (filters === undefined || filters.length === 0) return;

            const obj: VisualLevelFilter = {
              name: slicer.name,
              type: slicer.type,
              filters: filters,
            };
            slicerFilterData.push(obj); //Does not populate this when slicers are not on active page
          })
          .catch(
            (err) => {
              throw(err); //Errors here
            } 
          );
      }
}

Has anyone encountered this problem before, or does anyone have a workaround for this?

 

Much Appreciated

 

Graham

5 REPLIES 5
YM185
Regular Visitor

@Nojustice I have just come across the same issue. Have you found a workaround or been able to solve this?

Nojustice
Advocate I
Advocate I

Sorry I forgot to add the error 

 

 {"message":"visualConfigIsNotInitialized","detailedMessage":"Visual container config is not initialized"}
Anonymous
Not applicable

Hi @Nojustice,

According to your error message, it seems like your request did not include the configs so that it failed to initialize.

If that is the case, I'd like to suggest you take a look following links about power bi javascript and correspond configurations.

Configure report settings 

Embed Configuration Details 
Regards,

Xiaoxin Sheng

@Anonymous 

I have only provided an example piece of code, at the point this is executed the report is already rendered on the screen so all the configuration has already been passed to it.

 

As an example the report contains 2 tabs, 

Tab1 = Books

Tab2 = Authors

 

The user alters some slicers on Books, then moves to Authors and alters some slicers.

The user hits save (code in my original post is executed)

It seems to only getslicerstate from the slicers on the current page (in this case Authors), I want to store what the slicerstate is from Books page.

 

Hope this brings some more clarity

Anonymous
Not applicable

Hi @Nojustice,

So you mean you want to add data processing methods into the requests? Did this error disappear if you remove these operations? 

If that is the case, it may mean power bi not allow you to do some additional operation to send/access to the external resources.

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.