Forum Discussion

Log4TurtleShell's avatar
Log4TurtleShell
Frequent Visitor
3 years ago
Solved

How to get and set parameters on an Embedded Paginated Report

Hi all,   I have embedded reports and paginated reports in our website. For the regular reports I set up a bookmarking system using the powerbi-client javascript library to capture and apply boo...
  • Log4TurtleShell's avatar
    3 years ago

    EDIT: It appears the preferred way to pass these parameters is via the parameterValues property of IPaginatedReportLoadConfiguration. However, it seems IPaginatedReportLoadConfiguration is not importable from powerbi-client...

    https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/embed-paginated-report

     

    EDIT2: IPaginatedReportLoadConfiguration is importable from powerbi-client.models.

    private _paginatedReportConfig: models.IPaginatedReportLoadConfiguration = {
            type: 'report',
            id: '',
            embedUrl: undefined,
            tokenType: models.TokenType.Embed,
            accessToken: '',
            parameterValues: [
                { name: 'StartDate', value: '05/01/2023' },
                { name: 'EndDate', value: '05/22/2023' },
                { name: 'OtherParam', value: '86' },
            ],
            settings: {
                commands: {
                    parameterPanel: {
                        enabled: this.showParams,
                    },
                },
            },
        };

     

    ORIGINAL:

    https://learn.microsoft.com/en-us/power-bi/paginated-reports/parameters/pass-report-parameter-url

     

    I found one solution, passing parameters as query parameters in the EmbedUrl. I need to confirm that their is a way to disable the parameters section of the paginated report. I think it can be done by hiding all the params in Report Builder or maybe with a client-side option.

     

    Below is some basic code appending 3 parameters to the EmbedUrl.

     

     

     

    var paginatedReport = pbiClient.Reports.GetReportInGroup(workspaceId, paginatedReportId);
    
    paginatedReport.EmbedUrl += "&rp:StartDate=05%2F01%2F2023";
    paginatedReport.EmbedUrl += "&rp:EndDate=05%2F22%2F2023";
    paginatedReport.EmbedUrl += "&rp:OtherParameter=99";
    
     var tokenRequest = new GenerateTokenRequestV2(
    	reports: new List<GenerateTokenRequestV2Report>() { new GenerateTokenRequestV2Report(paginatedReportId) },
    	datasets: !string.IsNullOrEmpty(paginatedReport.DatasetId) ? new List<GenerateTokenRequestV2Dataset> { new GenerateTokenRequestV2Dataset(paginatedReport.DatasetId) } : null,
    	targetWorkspaces: new List<GenerateTokenRequestV2TargetWorkspace>() { new GenerateTokenRequestV2TargetWorkspace(workspaceId) },
    	identities: effectiveIdentities
    );
    
    pbiClient.EmbedToken.GenerateToken(tokenRequest);