Posted 16 January 2019, 12:07 am EST
- Updated 30 September 2022, 12:52 am EST
Hello Robert,
As per our understanding, you want to create the report through AR Server Designer. After the report is created, you want to call the report through an application using ARS rest API( I am assuming that you are previewing the report in HTML5 viewer). Also, I understand that Data in the report are coming from some external source like Web API that you want to set at runtime. You want to change the data according to some parameter like “Country”. When “Country” = USA, you want to show different data and when “Country” = Australia, you want to show some different data according to the name of the country.
You can use the ActiveReports Server for the creation of the report. You can create the repository of reports on the server. However, You need datasource and dataset to add the fields on the report while creating the report.
If my understanding is the correct, then you need to do the following steps:
Create a parametric json datasource(Managing Data Sources) on the server. You can refer to the following to add datasource on the server. I have used the public API “https://jsonplaceholder.typicode.com/posts?userId=” to create json datasource with the following connection string(img_DataSource):
=“jsondoc=https://jsonplaceholder.typicode.com/posts?userId=“+Parameters!ReportParameter1.Value+”;schemadata={ ‘definitions’: {}, ‘$schema’: ‘http://json-schema.org/draft-07/schema#’, ‘$id’: ‘http://example.com/root.json’, ‘type’: ‘array’, ‘title’: ‘The Root Schema’, ‘items’: { ‘$id’: ‘#/items’, ‘type’: ‘object’, ‘title’: ‘The Items Schema’, ‘required’: [ ‘userId’, ‘id’, ‘title’, ‘body’ ], ‘properties’: { ‘userId’: { ‘$id’: ‘#/items/properties/userId’, ‘type’: ‘integer’, ‘title’: ‘The Userid Schema’, ‘default’: 0, ‘examples’: [ 2 ] }, ‘id’: { ‘$id’: ‘#/items/properties/id’, ‘type’: ‘integer’, ‘title’: ‘The Id Schema’, ‘default’: 0, ‘examples’: [ 11 ] }, ‘title’: { ‘$id’: ‘#/items/properties/title’, ‘type’: ‘string’, ‘title’: ‘The Title Schema’, ‘default’: ‘’, ‘examples’: [ ‘et ea vero quia laudantium autem’ ], ‘pattern’: ‘^(.)$’ }, ‘body’: { ‘$id’: ‘#/items/properties/body’, ‘type’: ‘string’, ‘title’: ‘The Body Schema’, ‘default’: ‘’, ‘examples’: [ ‘delectus reiciendis molestiae occaecati non minima eveniet qui voluptatibus\naccusamus in eum beatae sit\nvel qui neque voluptates ut commodi qui incidunt\nut animi commodi’ ], ‘pattern’: '^(.)$’ } } }}”
Here, value of “parameters!ReportParameter1” is given through report
Create a dataset(https://help.grapecity.com/activereports/webhelp/AR12Server/ManagingDataSets.html) using the above datasource(img_DataSet).
Create the report using WebDesigner(https://help.grapecity.com/activereports/webhelp/AR12WebDesigner/webframe.html#Tutorial3CreateParameterizedReport.html).
Here, you can choose the above created dataset and create a parameter with name “ReportParameter1” and set the “Hidden” to “True”
Save the report
Now, you can preview or export the report using ARS Rest API
You can refer the following link to preview the above report with HTMl5 Viewer with ARS report service:
https://help.grapecity.com/activereports/webhelp/AR12Server/webframe.html#WorkHTML5ViewerUsingJavascript.html
You can give the different value of parameter to see the report according to different User ID using the following code:
report: {
id: ‘CustomersList’,
parameters: [
{
name: ‘ReportParameter1’,
value: ‘1’
}]
};
You can export the report using the following API:
https://help.grapecity.com/activereports/webhelp/AR12ServerAPI/index.html#!/rendering_requests/post_api_reports_id_jobs_render
If this is not your requirement, then could you please explain the following things:
From which type of application(HTML, MVC, WinForms), you are calling the report?
From where the data is coming?
Could you please explain the workflow and complete use case of your application in detail?
Are you previewing the report or exporting the report?
Thanks.