Have you ever been frustrated by a need to have a custom function in Reporting Services? There is an answer. Reporting Services allows you to add your own custom code. The code needs to be written in Visual Basic, but once you have your functions written in Visual Basic you can add them to your report!
Here's how:1. Go to the Report Menu and choose Report Properties.Once that is done, you'll want to use the function. Let's say I wanted to use a function called Myfunction on a field in my report called contact_id. To do this I would do the following:
2. Go to the Code Tab
3. Cut and paste your function(s) into the code window and click OK1. Choose the contact_id field.Note that you can also use things such as: =System.DateTime.Today in place of using a value from a dataset if you need to set a default for a date parameter for example. You can do this directly, without needing to create custom code (as long as it is part of the existing VB library that is).
2. Go to the properties pane for that field and scroll to the value property.
3. Click the down Arrow and choose <Expression>.
4. In the expression window type =Code.MyFunction(Fields!contact_id.Value)
5. Press OK
If you are feeling adventurous, you might have noticed that in the properties for your report you can also add your own references and classes!
Enjoy![]()



LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks