cec7607d4dbfb83afe1a16a91fcda7cf65255a7a
API/CodeSamples/ExpressionFunctions.md
| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | +#ExpressionFunctions |
|
| 2 | + |
|
| 3 | +[[_TOC_]] |
|
| 4 | + |
|
| 5 | +##About |
|
| 6 | + |
|
| 7 | +This list allows the user specify additional SQL functions that should be accessible in an [[Expression|http://wiki.izenda.us/Guides/ReportDesign/15.0-Expressions-in-Izenda]]. This setting can be used at the same time as [[Extended Functions|http://wiki.izenda.us/API/CodeSamples/ExtendedFunctions]]. |
|
| 8 | + |
|
| 9 | +Below is a sample global.asax using the ExpressionFunctions setting. The code block will appear within ``<script runat="server"> </script>`` tags within global.asax. |
|
| 10 | + |
|
| 11 | +##Best Practices |
|
| 12 | + |
|
| 13 | +- If a function will be used ONLY in an Expression, then you should use the ExpressionFunctions setting. Otherwise, use ExtendedFunctions to allow the function to be placed into the dropdown Function list in the report designer. |
|
| 14 | + |
|
| 15 | +- You should not use parentheses when you specify a function in ExtendedFunctions or ExpressionFunctions. All we want to do in these settings is list the function name itself, and not call the function. |
|
| 16 | + |
|
| 17 | +- When you specify a function in ExtendedFunctions you should use the full function name with schema. When you specify it in ExpressionFunctions short name is sufficient. |
|
| 18 | + |
|
| 19 | +##Global.asax (C♯) |
|
| 20 | + |
|
| 21 | +```csharp |
|
| 22 | +//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 23 | +public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig |
|
| 24 | +{ |
|
| 25 | + // Configure settings |
|
| 26 | + // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method |
|
| 27 | + public static void InitializeReporting() { |
|
| 28 | + //Check to see if we've already initialized. |
|
| 29 | + if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 30 | + return; |
|
| 31 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"; |
|
| 32 | + //Creates a connection to Microsoft SQL Server |
|
| 33 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"; |
|
| 34 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 35 | + AdHocSettings.ExpressionFunctions = new string[] { "DATEADD", "LEFT" };//The relevant setting |
|
| 36 | + HttpContext.Current.Session["ReportingInitialized"] = true; |
|
| 37 | + } |
|
| 38 | +} |
|
| 39 | +``` |
|
| 40 | + |
|
| 41 | +##Global.asax (VB.NET) |
|
| 42 | + |
|
| 43 | +```visualbasic |
|
| 44 | +'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 45 | +Public Class CustomAdHocConfig |
|
| 46 | + Inherits Izenda.AdHoc.DatabaseAdHocConfig |
|
| 47 | + |
|
| 48 | + Shared Sub InitializeReporting() |
|
| 49 | + 'Check to see if we've already initialized |
|
| 50 | + If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then |
|
| 51 | + Return |
|
| 52 | + 'Initialize System |
|
| 53 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE" |
|
| 54 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE" |
|
| 55 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = New CustomAdHocConfig() |
|
| 56 | + AdHocSettings.ExpressionFunctions = New String() { "DATEADD", "LEFT" } 'The relevant setting |
|
| 57 | + HttpContext.Current.Session("ReportingInitialized") = True |
|
| 58 | + End Sub |
|
| 59 | +End Class |
|
| 60 | +``` |
|
| ... | ... | \ No newline at end of file |