Issue with Passing Authorization Token in Telerik Web Report Designer

1 Answer 24 Views
Report Designer - Web Report Parameters
Krunal
Top achievements
Rank 1
Iron
Iron
Krunal asked on 28 Feb 2025, 11:17 AM

We have embedded Telerik report designer in our angular web application. Reports which we have designed has web api datasources in it which requires authorization token. All the reports have a parameter named token defined in it in which we need to pass on the value of latest token when designer opens up. But not able to figure out the way to pass/update the parameter value when I'm opening the report designer. Following is the code we have to open report designer. 

    this.designer = $('#webReportDesigner')
      .telerik_WebReportDesigner({
        serviceUrl: `${environment.apiUrl}/reportdesigner/`,
        report: reportName != null ? `${reportName}` : false,
        parameterAreaPosition: 'left',
        parametersAreaVisible: true,
        interactive: true,
        tools: [
          { name: 'openReport' },
          { name: 'save' },
          { name: 'undo' },
          { name: 'redo' },
          { name: 'preview' },
        ],
        documentMapAreaPosition: 'left',
      })
      .data('telerik_WebReportDesigner');
With this code in place, I don't seem to find any way to update the report parameter value when I'm opening up the report in report designer. Can anyone pls help with this?

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 05 Mar 2025, 09:00 AM

Hello Krunal,

Thank you for providing the code snippet of your report designer.

You can set the report parameters for the designer on the client side through the reportViewerOptions option, which can take a reportSourceParameters object. You can find more information about this in the following article from our documentation:

Alternatively, you can manage them on the server side by implementing a CustomReportSourceResolver. For instance, when you preview the report in the web report designer, a request is made to the REST service to resolve and render the report using a report source resolver. By implementing a CustomReportSourceResolver, you can access and modify its report parameters during this process through its Resolve method.

Below is a sample implementation that modifies the currentParameterValues dictionary passed to the Resolve method:

    class CustomReportSourceResolver : IReportSourceResolver
    {
        public Telerik.Reporting.ReportSource Resolve(string reportId, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
        {
            var uriReportSource = new Telerik.Reporting.UriReportSource()
            {
                Uri = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Reports", "SampleReport.trdp")
            };

            currentParameterValues["Id"] = "1";

            return uriReportSource;
        }
    }

You can read more information on how to attach this report resolver to your REST service, as well as further details on this topic, in the following documentation article:

Also, please note that if you choose to modify the report parameters using a CustomReportSourceResolver on the server, the parameters you pass from the client to render the report viewer will be overridden by those passed on the server.

I hope you find this helpful. Please let me know if you need any further assistance on this matter.

Regards,
Petar
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Krunal
Top achievements
Rank 1
Iron
Iron
commented on 25 Mar 2025, 01:32 PM

As per your suggestion, I have added following code 

 BindReportDesigner(reportName: string | null) {
    var token = localStorage.getItem('access_token');
 
    this.designer = $('#webReportDesigner')
      .telerik_WebReportDesigner({
        serviceUrl: `${environment.apiUrl}/reportdesigner/`,
        report: reportName != null ? `${reportName}` : false,
        parameterAreaPosition: 'left',
        parametersAreaVisible: true,
        interactive: true,
        tools: [
          { name: 'openReport' },
          { name: 'save' },
          { name: 'undo' },
          { name: 'redo' },
          { name: 'preview' },
        ],
        documentMapAreaPosition: 'left',
        reportViewerOptions : {
          reportSourceParameters : {
            '_rptname' : 'temp123'
          }
        }
      })
      .data('telerik_WebReportDesigner');
  }

In the code, I have added reportSourceParameters value object and in that I'm trying to pass the value of parameter with the name "_rptname" as "temp123" but it is not picking up this value when I open the report designer. 

Can you point out is this correct approach or if I'm missing something?

Petar
Telerik team
commented on 28 Mar 2025, 11:38 AM

Hello Krunal,

Initially, I believed you expected the values to be provided when using the "Preview" functionality of the web report designer:

Previewing processes the report and populates it with actual values. In this case, setting the reportSourceParameters options should work if you are using Telerik Reporting version 18.0.24.130 or higher:

However, it seems that you expect the value to be available once the report is loaded in the web report designer, even before it is previewed. Could you please confirm if this is correct? If this is the case, you would be able to work with the fields provided by the web report designer in situations where the authorization token has changed, without needing to perform any additional setups:

The values utilized in the report and accessible during the design time are actually embedded within the report definition. Currently, the only intended way to modify these values is directly through the web report designer. That being said, the ability to change these values by passing them during the initialization of the web report designer seems like a valuable feature to me. Therefore, I encourage you to submit this suggestion in our public feedback portal:

If there is enough interest from the community, we will definitely consider implementing it in a future release.

If you believe that I misunderstood your use case or if you have any additional concerns regarding this matter, please feel free to reach out, and I'd be happy to provide further insights.

Regards,

Petar

 

Tags
Report Designer - Web Report Parameters
Asked by
Krunal
Top achievements
Rank 1
Iron
Iron
Answers by
Petar
Telerik team
Share this question
or