Report Builder Custom code examples
Hi
are there any examples out what can be done using custom code in a report?
any documentation on that?
Regards
Klaus
Hi
I already found this side.
I am searching for a kind of object model description, that shows me which properties / methods are existing, for example:
Report.Parameters is a build in collection.
I like to see a documentation, which properties/methods are available (buildin to the reportbuilder)
Maybe there is a way to show the interface in the object browser of visual studio?
Regards
Klaus
Similar Messages
-
Flash Builder custom code folding
I've just donwloaded the new CC versions and will possibly be buying the subscription at the end of this month. I was previously using CS4 versions.
One thing I noticed though, is that the custom code folding options in the Flash CC actionscript editor are gone, you can now only collapse entire functions. This remains true for flash builder as well.
So is there any way to collapse custom regions in flash builder instead of just entire functions? I'm working on a flash MMO and I've got over 10,000+ lines of code. Being able to collapse only functions simply doesn't cut it. It really hinders my development time as I have to scroll through masses of code in order to get to what I need. It's also much much more confusing looking at thousands of lines of code that I don't need to see at the moment. Visual studio has a way of defining regions by typing "#region" and "#endregion" in the area you wish to collapse. Is there anything I can do about this? This is a very very important feature (at least for me) that I'm not sure why it was left out, or I am unable to find it.
Thanks.I've just donwloaded the new CC versions and will possibly be buying the subscription at the end of this month. I was previously using CS4 versions.
One thing I noticed though, is that the custom code folding options in the Flash CC actionscript editor are gone, you can now only collapse entire functions. This remains true for flash builder as well.
So is there any way to collapse custom regions in flash builder instead of just entire functions? I'm working on a flash MMO and I've got over 10,000+ lines of code. Being able to collapse only functions simply doesn't cut it. It really hinders my development time as I have to scroll through masses of code in order to get to what I need. It's also much much more confusing looking at thousands of lines of code that I don't need to see at the moment. Visual studio has a way of defining regions by typing "#region" and "#endregion" in the area you wish to collapse. Is there anything I can do about this? This is a very very important feature (at least for me) that I'm not sure why it was left out, or I am unable to find it.
Thanks. -
Can we build custom code in xsl-xml
Hi, We are using one of the .xml dump which is stored as a row in the table iby_trxn_documents
We are mapping .xsl (a custom template with the above .xml tags)
We are getting the below tags in .xml (which is stored in table iby_trxn_documents) but the value is not populated in the tags,
We have build one one sequence in the database, where we need to map the incremented value of the sequence in that place.
My (xml looks like any of the below two options)
- <PaymentSequence>
<SequenceName />
<LastValue />
</PaymentSequence>
In this case i am getting output as W
- <PaymentSequence>
<SequenceName>XX_SEQ</SequenceName>
<LastValue>1</LastValue>
</PaymentSequence>
in this case i am getting output as W1, but for next run i want it as W2 etc... or is there any option we can get incremented values in <Creation_Module>
as my above value is coming null, in my output also i am getting null.
Is there a way i can get the value of sequence in my xsl template.
I am writing some thing like this in my (.xsl)
- <Creation_Module>
<xsl:value-of select="concat('W',/PaymentSequence/LastValue)" />
</Creation_Module>
For every run i want this last value to be incremented by 1
Appreciate if some one has any knowledge in this.
Thanks...
Edited by: 902157 on Aug 27, 2012 9:18 AMHi, We are using one of the .xml dump which is stored as a row in the table iby_trxn_documents
We are mapping .xsl (a custom template with the above .xml tags)
We are getting the below tags in .xml (which is stored in table iby_trxn_documents) but the value is not populated in the tags,
We have build one one sequence in the database, where we need to map the incremented value of the sequence in that place.
My (xml looks like any of the below two options)
- <PaymentSequence>
<SequenceName />
<LastValue />
</PaymentSequence>
In this case i am getting output as W
- <PaymentSequence>
<SequenceName>XX_SEQ</SequenceName>
<LastValue>1</LastValue>
</PaymentSequence>
in this case i am getting output as W1, but for next run i want it as W2 etc... or is there any option we can get incremented values in <Creation_Module>
as my above value is coming null, in my output also i am getting null.
Is there a way i can get the value of sequence in my xsl template.
I am writing some thing like this in my (.xsl)
- <Creation_Module>
<xsl:value-of select="concat('W',/PaymentSequence/LastValue)" />
</Creation_Module>
For every run i want this last value to be incremented by 1
Appreciate if some one has any knowledge in this.
Thanks...
Edited by: 902157 on Aug 27, 2012 9:18 AM -
Custom code dll as a data source for an SSRS report
I'm trying to create a report which relies on using some custom code written in VB.net. I am using the custom code to access the Server Management Objects SMO API in MSSQL 2012. I am able to supply an MSSQL object name (a database table
for example)and then return a list of dependant objects using the dependency walker class (stored procedures, triggers, UDF's, other tables etc.) which rely on the parent object if you will. I am able load the results into a dataset in the custom code. My
question is how can I get that dataset to be consumed as a data source and appear in my report. I've read many articles on how to use scripts to supply values for various report property settings. I just haven't seen an example of using a dll
to supply a dataset. I am assuming it is possible. Any thoughts or advice would be appreciated. CheersHi mdmck,
According to your description, you want to create an SSRS report with custom code as data source, right?
To use custom code in Reporting Services, we need to add a reference to your custom assembly, create a new CodeGroup for your custom assembly, and then grant full trust permissions. For detail information, please refer to the following steps:
Open the report that will reference the custom assembly.
On the Report menu, click Report Properties.
In the Report Properties dialog box, click the References tab.
Under References, click the ellipsis (...) button that is next to the Assembly name column header.
In the Add References dialog box, click Browse.
Locate and then click the custom assembly. Click Open.
In the Add References dialog box, click OK.
In the Report Properties dialog box, click OK.
If the custom assembly requires more permissions than the default Execution level permissions, we need to create a new CodeGroup for your custom assembly, and then grant full trust permissions.
Here are relevant threads you can reference:
https://social.technet.microsoft.com/Forums/en-US/c297bddc-c33c-4386-b284-41c1d87f37c6/custom-dlls-in-ssrs-reports?forum=sqlreportingservices
https://social.technet.microsoft.com/Forums/en-US/27de3f46-5174-480d-b4d1-5e32772dae35/ssrs-2005-custom-code-shared-data-source-connection-string?forum=sqlreportingservices
For more information about How to use custom assemblies or embedded code in Reporting Services, please refer to the following document:
https://support.microsoft.com/kb/920769?
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
If you have any feedback on our support, please click
here.
Wendy Fu
TechNet Community Support -
I have a SSRS report that parses RTF to TXT and displays it in a report. The report works fine and everything displays correctly. The subscription email, however, contains a report with errors: Request for the permission of type
'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The report contains embedded code as well as references to System.Security and System.Windows.Forms. I've updated .....\Reporting Services\ReportServer\rssrvpolicy.config and ....\Reporting Services\ReportManager\rsmgrpolicy.config to change permissions
to FullTrust. Not sure what else I need to do. Please help.Hi Chimuelo,
According to your description, if the report contains custom code and assemblies, the subscription email contains an error “Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed”.
In your scenario, the issue could cause by that the report can’t access those assemblies. Please modify the policy configuration files to grant additional permissions for those assemblies. For more information, please refer to this article:
How to grant permissions to a custom assembly that is referenced in a report in Reporting Services.
Similar thread for your reference:
Custom assembly throwing #error in reports with subscriptions
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
How to use LIKE function with a parameter in Oracle REPORT builder??
how could i use parameter inside a LIKE function in Oracle reports builder?
it works in SQL plus, but not in report builder!!
Example:
select code,desc from item_master where desc
like '%&give_desc%'; ---works in SQL
like '%:give_desc%' ---doesn't work in report builder!!Hi Renil,
You will need to use the wildcard character (%) and the concatenation character (||) to join to your user parameter.
i.e. like '%'||:give_desc||'%'
Regards,
John -
SSRS Running Totals Custom Code
I have a report in which I need to total a column with an expression and created simple code to have a running total. When I run the report through report builder, the total only reflects the current page (it is 6 pages long) but if I export the report
out to Excel, the total is correct.
Below is the code:
Public running_roy as Double = 0
Public Function roy_tot(ByVal cust_type, ByVal roy, ByVal ret_value) as Double
Dim temp_var as Double
if cust_type = 0 then
running_roy = running_roy + roy
if ret_value = 0 then
temp_var = roy
else
temp_var = running_roy
end if
ELSE
temp_var = 0
end if
return temp_var
End Function
If I change the Public variable to "Public Shared" the totals change as I flip back and forth between the pages in report builder.
Any suggestions?Hello alan2624,
Thanks for your clarification.
In the report, the custom code will be compiled as a class before it is used. Every time the page is loaded, the class on the page will be initialized. The un-shared (non-static) instance will be reset. Therefore, you will see the value is reset back to
zero if the public variable is not announced as "Shared". If you announced it as shared, then the variable is on the class level. It will not be changed by instance initializing. In addition, any operations on the variable will be recorded. This is not the
bug, but it is by design of the VB.net code.
If you export the report to the Excel, I think it will only generate a single page, and the total value is only the last one. It should be correct. If it is used in the pages in browser, I suggest you need design your code carefully for VB.net design.
If you have any questions about this issue, please let me know.
Regards,
Edward
Edward Zhu
TechNet Community Support -
In Report Builder 3.0, I have the following custom code entered:
Public Function SafeDivide(Numerator as String, Denominator as String) as String
Try
If Numerator = “” or Denominator = “” then
Return “-“
End if
If Numerator = “-“ or Denominator = “-“ then
Return “-“
End If
If CDbl(Numerator) =0 or CDbl(Denominator) = 0 then
Return “-“
End if
If IsNothing(Numerator) or IsNothing(Denominator) then
Return "-"
End if
Return Val( ( (CDbl(Numerator) / CDbl(Denominator) )*100 ) )
Catch
Return "-"
End Try
End Function
I call the custom code in the cell with the following equation:
=Code.SafeDivide(sum(Fields!TY_UNITS.Value)-sum(Fields!LY_UNITS.Value),sum(Fields!LY_UNITS.Value))
I have the format for the cell set to 0.00%, but it’s not being followed.
I want the result to be formatted as a Percentage, but instead I get values like:
-78.9473684210
80
300
-100
I have the format for the cell set to 0.00%, but it’s not being followed.
How do I do use the custom code and format for a percentage with 2 decimals?Hi AngP,
After testing the issue in my local environment, I can reproduce it. Based on my research, I find this issue is caused by the type of Units_VAR_Percentage cell is string, while the type of CDbl(Parameters!Var_Threshold.Value) is double, so they cannot be
compared.
To fix this issue, we can add a hidden column (Textbox91) next to the Units_VAR_Percentage column, and type =(sum(Fields!TY_UNITS.Value)-sum(Fields!LY_UNITS.Value)) /sum(Fields!LY_UNITS.Value) as the expression. Then use the expression below to control the
BackgroundColor:
=iif(iif(reportitems!Units_VAR_Percentage.Value=CStr(format(reportitems!Textbox91.Value,"0.00%")),reportitems!Textbox91.Value,0)>CDbl(Parameters!Var_Threshold.Value),"Yellow","PaleTurquoise")
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to query a dataset using custom code in report builder 3.0
Hi,
Can anyone please suggest whether it is possible to query a dataset by using custom code in report builder 3.0.
Thanks in advance.Hi Purbasha,
please see below similar thread:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9af8f39a-9dc5-49ab-91af-2f64198c8477/ssrs-2008-custom-code-for-database-query
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/440ff5de-1c21-47de-95d8-e4212d6cef6d/dataset-in-custom-code-in-sql-server-reporting-services?forum=sqlreportingservices
swallow -
Hello all,
I want to build custom report using oracle report 6i by using XML
how can do this and is there any manuals or documents or reference about the
instruction of XML for example i found in the demo this code :
AddaLine(' <data>', custom_summary);
AddaLine(' <dataSource name="Q_1">', custom_summary);
AddaLine(' <select>', custom_summary);
AddaLine(' SELECT ALL VIDEO_CATEGORY_BY_QTR.QUARTER quarter1,
VIDEO_CATEGORY_BY_QTR.CITY city1, ',custom_summary);
AddaLine(' VIDEO_CATEGORY_BY_QTR.PRODUCT_CATEGORY
product_category1, VIDEO_CATEGORY_BY_QTR.TOTAL_PROFIT
total_profit1,',custom_summary);
AddaLine(' VIDEO_CATEGORY_BY_QTR.TOTAL_SALES total_sales1,
VIDEO_CATEGORY_BY_QTR.TOTAL_COST total_cost1',custom_summary);
AddaLine(' FROM VIDEO_CATEGORY_BY_QTR',custom_summary);
AddaLine(' WHERE
VIDEO_CATEGORY_BY_QTR.SALES_REGION=''West''',custom_summary);
AddaLine(' </select> ',custom_summary);
AddaLine(' </dataSource>',custom_summary);
i need your help and thanks
samerHi,
In order to gather schema statistics in EBS, you will have to login as Sysadmin and submit a request named as "Gather Schema Statistics"
Refer below link:
http://appsdba.info/docs/oracle_apps/R12/GatherSchemaStatistics.pdf
Also ensure to schedule the respective request so as to have your statistics up to date, either weekly or monthly as per your system environment.
Please refer note:
How Often Should Gather Schema Statistics Program be Run? [ID 168136.1]
How to Gather Statistics on Custom Schemas for Ebusiness Suite 11i and R12? [ID 1065813.1]
Hope this helps!
Best Regards -
SCCM 2012 R2 CU2 Can't Edit WMI Query Code in Report Builder
I first posted this in the SCCM but the issue is not solved so I thought I'd try here in the SQL Reporting forum. Original thread here: http://social.technet.microsoft.com/Forums/en-US/b0a6ca3d-7471-4b49-8447-7403a65c2ec0/sccm-2012-r2-cu2-cant-edit-wmi-query-code-in-sccm-reports?forum=configmanagergeneral
I'll repost info here to make this easier.....
I built a new SCCM 2012 R2 CU2 suite on Server 2012 R2. This also uses SQL 2012 SP1 CU6. This suite has 4 servers: site server, two for WSUS and secondary DPs, and SQL. This problem is true for the built in reports and my custom reports. Our SQL guy has
been helping me a lot but we've gotten nowhere. I can run a report. I can open one in edit mode after it prompts me for credentials. It loads Report Builder 3.0. But when I go to a dataset/query, enter credentials, and try to open it, I get a popup that
says "Unable to connect to data source. 'AutoGen_5C6358F2_yayak..." When I click on details it says "The target principal name is incorrect. A connection was succesfully established with the server, but then an error occurred during the login
process. (SSL Provider, error: 0 -The target principal name is incorrect.)" In SQL Reporting Services Config Manager the paths for Web Service URL is
http://ip.ip.ip.ip:80/ReportServer_SC01 and for Report Manager URL:
http://ip.ip.ip.ip:80/Reports_SC01. A domain account is used to login. This happens when you r-click a dataset and select query to edit the code of a dataset, ie, when query designer tries to open up. It happens
in both Admin Console and when using the Report Manager URL within SQL SSRS. All other functions of using edit mode of a report work fine.
Ben JohnsonWYWhen I do that, browse is dimmed out.
But, if I deselect "create a data set" and click "choose an existing dataset in this report..." there is no data connection at the end.
But if I don't use report builder and instead use IE to browse to my ConfigMgr_ABC, I do see the connection at the end: {123...}.
This problem is on a network that is not on the 'net, so it's hard to do screen shots, so I'll reproduce this problem step by step:
I pick a report to edit, it doesn't matter which one.
If I try it in Admin Console, I right-click, Edit the report, it asks me for a login, I login, then I get a popup that says "Cannot continue. The application is improperly formatted. Contact the vendor for assistance. I click the Details button and
get a long set of text but the key part is "Your web browser settings do not allow you to run signed applications." This msg didn't appear before, so something changed, so I will investigate. I think it used to give a SPN error.
If I use IE within report builder and navigate to whatever report, click open, everything works, except, when I click on Dataset0 (the key one I normally need to edit), click query, it prompts me for a login and no matter which one I use, i get a popup that
says "unable to connect to data source 'AutoGen_123...'". If I click details I get "the targe principal name is incorrect. A connection was successfully established with the server, but then an error occurred during the login process. (provider:
SSL Provider 0-The target principal name is incorrect.)
Ben JohnsonWY -
How to control or manipulate a report parameter through SSRS Custom Code
Hi,
In reporting services 2005 or 2008, is it possible to control the parameters inside the custom code of a report?
for example:
Let's say I have a parameter that displays the following value:
Red
Green
Blue
In typical scenario I can select one of the values or I can select all of the values then click the View Report button in reporting services.
I know that this approach is much easier to do if I have an external application like ASP.Net and from there I'll just add report viewer and control the parameters to be passed and then generate the report.
In the report I added text box that will serve as a hyperlink to refresh report:
In the Text Box Properties\Action tab. Is it possible to control the selection of values through a custom code(SSRS Custom Code) then the report will be automatically refreshed?
thanks,
JoeferNot sure about doing a multiple selection. But you can pop up an input box to get the input on the fly.
Add the below custom code and expression for the above parameter
Public function Getparamvalue() AS STRING
Dim x as STRING
x = InputBox("Enter Red / Blue / Green")
Return(x)
End function
=Code.Getparamvalue() -
Function MakeList(ByVal items As Object()) As String
If items Is Nothing Then
Return Nothing
END if
Dim builder As System.Text.StringBuilder =
New System.Text.StringBuilder()
builder.Append("<div>")
For Each item As Object In items
builder.Append("<div <ul>")
builder.Append(item)
builder.Append("</ul>")
Next
builder.Append("</div>")
Return builder.ToString()
End Function
Function Length(ByVal items as Object()) as Integer
If items is Nothing Then
Return 0
End If
Return items.Length
End FunctionHi Wintersbay,
According to your description, when you use the custom code in SSRS report, you got the error message.
To solve the problem, please refer to the custom code below:
Function MakeList(ByVal items As Object) As String
If items Is Nothing Then
Return Nothing
END if
Dim builder As System.Text.StringBuilder =
New System.Text.StringBuilder()
builder.Append("<div>")
For Each item As Object In items
builder.Append("<div <ul>")
builder.Append(item)
builder.Append("</ul>")
Next
builder.Append("</div>")
Return builder.ToString()
End Function
Function Length(ByVal items as Object) as Integer
If items is Nothing Then
Return 0
End If
Return items.Length
End Function
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
Hi,
I Haven't used Vb.net, as I work on C#, But in SSRS it supports only VB.net code as custom coding, so i coded in c# and converted to VB.net from online converter. The code i got from online converter is working fine in local i.e when i preview in BI studio,
but when i try to deploy the same i'm getting error
Error 3
There is an error on line 12 of custom code: [BC30201] Expression expected.
0 0
Below is the code:
' -- Author : Jai Anand
' -- Date : 06-05-2014
' -- Discription : To split the given string of numbers and Assign the days for it,
' -- example: if integer 1 - (Su) --> Sunday, 2 - (Mo) --> Monday
public Function FindPlanDays(plandate As String) As String
Dim planarray As String() = New String() {}
Dim days As String = ""
planarray = plandate.Split(","C)
Dim i As Integer = 0
While i < planarray.Length
Dim day As String = If(planarray(i) = "1", "Su,", If(planarray(i) = "2", "Mo,",
If(planarray(i) = "3", "Tu,", If(planarray(i) = "4", "We,", If(planarray(i) = "5", "Th,", If(planarray(i)="6","Fr,", If(planarray(i) = "7", "Sa,", String.Empty)))))))
days = days & day
i += 1
End While
days = If(days <> String.Empty, " (" + days.TrimEnd(","C) + ")", days)
Return days
End Function
Kindly check the code, if any issue is there,give me the solution..Thank youHi,
I found the solution and the report is deployed . The issue was with If and we should suffix with space and underscore( _) at the end of the line break and continues in next line (i.e if the statement continues in next line).
iif has always been available in VB, even in VB6.
Dim day As String = Iif(planarray(i) = "1", "Su,","Mon")
It is not a true operator, as such, but a function in the Microsoft.VisualBasic namespace.
so the modified code which worked fine to deploy
' -- Author : Jai Anand
' -- Date : 06-05-2014
' -- Discription : To split the given string of numbers and Assign the days for it,
' -- example: if integer 1 - (Su) --> Sunday, 2 - (Mo) --> Monday
public Function FindPlanDays(plandate As String) As String
Dim planarray As String() = New String() {}
Dim days As String = ""
planarray = plandate.Split(","C)
Dim i As Integer = 0
While i < planarray.Length
Dim day As String = Iif(planarray(i) = "1", "Su," ,Iif(planarray(i) = "2", "Mo,", _
Iif(planarray(i) = "3", "Tu,", Iif(planarray(i) = "4", "We,", Iif(planarray(i) = "5", "Th,", _
Iif(planarray(i) ="6","Fr,", Iif(planarray(i) = "7", "Sa,", String.Empty)))))))
days = days & day
i += 1
End While
days = Iif(days <> String.Empty, " (" + days.TrimEnd(","C) + ")", days)
Return days
End Function -
SSRS custom code for count in Report Footer
Hi All,
Please help me with the custom code used for below requirement
Debtor Name current 30+days 60+days 90+days
aaa 7000 0.00 0.00 10.00
bbb 5000 0.00 20.99 3.00
ccc 1000 0.00 0.00 0.00
Expected result in report footer :
0 1
2
if the value of 30+ , 60+ and 90+ columns >=1 then i have to display the count in Report footer,for that i have tried using a custom code like below :
Shared Dim OD As Integer=0
Public Shared Function Test(ByVal OP As Decimal) As Integer
If OP >= 1 Then
OD = OD + 1
Else
OD = OD
End If
Return OD
End Function
and using below code to display
Code.Test(Overdue)
but when i use this code in report footer is not displaying correct value.Please guide me where i am going wrong.
Please let me know if you need any other details.
Thanks in advance,
Samhith.Hi Samhith,
Per my understanding you what to count the rows which values >=1 and display them at the bottom of the table, you are trying to use the custom code to do this but failed, right?
I have tested in my local environment and find the custom code is not correctly, and I have an alternative method which is more easy and can work in both table and matrix.
As Vaibhav Chaudhari also mentioned that we can use the CountDistinct function, but more correctly, we can use the count() function and the RunningValue() function, because CountDistict will not count the duplicated values if they >=1.
Please find the expression as below:
=Count(IIf(Fields!Yourfield.Value>=1 , Fields!Yourfield.Value, Nothing))
OR:
=RunningValue(IIf(Fields!Yourfield.Value>=1 , 1, Nothing),Sum,"DataSetName")
If you still have any problem, please feel free to ask.
Regards
Vicky Liu
Maybe you are looking for
-
Streamed videos freeze and don't start back up. My iPad is new and already having issues. Stalls on wifi and 3G. Is this typical?
-
XML Newbie - Help Processing Files!
I'm not exactly sure if "process" is the right word, so I'll describe what I mean. There are two XML files (http://xml.pinnaclesports.com/xmlfeed.asp and http://208.138.39.112/XMLLineFiles/Baseball.xml) that are constantly updated online, and I want
-
Vertical Ruler and Preprinted Forms
I am creating a Bill of Lading in CR2008 which must be printed on a preprinted form on a dot matrix printer. There are boxes which have to have information in them. I can measure on the form from the top and left where the data needs to go, but whe
-
Laggy timeline, playhead line not lined up with playhead after 8.1 update!
Is anyone else experiencing this??? See attached screen shot. The white line is sticking all over the time indicator resulting in what you see below, also, the playhead line is not actually lined with the playhead itself, making frame edits completel
-
Mac Pro 5,1 Fans full throttle, SMC reset does not help
Hello Community, i have the following issue: - Mac Pro 5,1 - Latest Firmware; no SMC update available - Fans (of case, not graphics card) running full throttle as soon as OS X is active (installed or in a installation phase). - During boot up, fans r