Document Management
How To and Troubleshooting
Wyn Enterprise has a variety of functions to perform date-time, mathematical, comparison, aggregation, text, and other operations. If these functions are not sufficient, a user can add new functions to Expression Editor with syntax, description, and example, like the built-in functions.
See the example below that uses a user-defined function, CountChar, to count the occurrences of a specified character in a string.
Following is the code for the CountChar function defined in CSharp and Visual Basic.
CSharp -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --- -- -- -- -- -- -- -- -- -- -- -- -- /// <function name="CountChar"> /// <culture> /// <label>CountCharacter</label> /// <syntax>CountChar(<str>, <char>)</syntax> /// <description>Returns the number of occurrences of the specified character in the string.</description> /// <example>Code.CountChar("Wyn Enterprise", "e")</example> /// </culture> /// </function> public int CountChar(string str, string ch) { return str.Length - str.Replace(ch, "").Length; }
Visual Basic -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --- -- -- -- -- -- -- -- -- -- -- -- -- ''' <function name="CountChar"> ''' <culture> ''' <label>CountCharacter</label> ''' <syntax>CountChar(<str>, <char>)</syntax> ''' <description>Returns the number of occurrences of the specified character in the string.</description> ''' <example>Code.CountChar("Wyn Enterprise", "e")</example> ''' </culture> ''' </function> Public Function CountChar(str As String, ch As String) As Integer Return str.Length - str.Replace(ch, "").Length End Function
These functions are added and managed by the admin user role on the User Functions page of the Admin Portal.
Type the function code manually or upload a file containing the function code. The code must include XML descriptions that provide function-related information including name, label, syntax, description, and example, to display in the Expression Editor. On successful code compilation, the function will appear in the Expression Editor of the Report Designer.
Note: 1. Make sure to specify the XML descriptions, else the function will not appear in the Expression Editor. However, you can use that function by following its syntax, for example, {code.samplefunction(argument1, argument2…)}.2. Use HTML codes for less than and greater than symbols to avoid any compilation error.
With Wyn Enterprise, you can add multiple user functions depending on your requirements. It also lets you create more than one function with the same name if they have different arguments. These functions are implemented in CSharp or Visual Basic.
Follow the below steps to add user functions in Wyn Enterprise.
Tip: Click Generate to produce a sample function code with XML descriptions.
Then, click Compile to see compilation errors if any, and then select Save.
Note: The Save button is enabled when the function code for the available language(s) is compiled explicitly with no compilation errors.
The user function is now listed under the User Functions node of the Expression Editor in the Report Designer.