API/CodeSamples/DynamicReportCreation.md
... ...
@@ -0,0 +1,41 @@
1
+#Dynamically Creating Reports Via the API
2
+
3
+[[_TOC_]]
4
+
5
+##Process
6
+
7
+This code sample allows a user to create reports using API calls. Any tables added to the **JoinedTables** list must be in the current user's [[VisibleDataSources|/API/CodeSamples/VisibleDataSources]](usually handled in [[ConfigureSettings|/FAQ/ConfigureSettings]] or [[PostLogin|/FAQ/PostLogin]]) before the **CurrentReportSet** is processed. When a report is created this way, a Response.Redirect() call to the Report Viewer page will allow the user to view the report. Alternately, you can redirect to **rs.aspx** using the [[output query string parameter|/FAQ/Questions/Query-String-Keys-for-rs.aspx]] and create fully formed PDFs and Excel-formatted reports with the click of a button.
8
+
9
+###C♯ Sample
10
+
11
+```csharp
12
+ReportSet rs = new ReportSet();
13
+rs.ReportName = "Generated Report";
14
+
15
+JoinedTable jt = new JoinedTable();
16
+jt.TableName = "[dbo].[Orders]";
17
+rs.JoinedTables.Add(jt);
18
+
19
+Field f = new Field("[dbo].[Orders].[ShipCountry]", "Ship Country");
20
+
21
+rs.Detail.Fields.Add(f);
22
+
23
+Izenda.AdHoc.AdHocContext.CurrentReportSet = rs;
24
+```
25
+
26
+###VB.NET Sample
27
+
28
+```
29
+Dim rs As New ReportSet()
30
+rs.ReportName = "Generated Report"
31
+
32
+Dim jt As New JoinedTable()
33
+jt.TableName = "[dbo].[Orders]"
34
+rs.JoinedTables.Add(jt)
35
+
36
+Dim f As New Field("[dbo].[Orders].[ShipCountry]", "Ship Country")
37
+
38
+rs.Detail.Fields.Add(f)
39
+
40
+Izenda.AdHoc.AdHocContext.CurrentReportSet = rs
41
+```
... ...
\ No newline at end of file