I am trying to attach a SSRS report in a prepopulated email and send it. In order to do this, am trying to mimic a JS function which creates a new email with the PDF button attached on click.
What is thr equivalent of the following JS code in C#?
var reEntReq = new XMLHttpRequest();
reEntReq.open("POST", pth, false);
reEntReq.setRequestHeader("Accept", "*/*");
reEntReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
reEntReq.send(query);
//These variables captures the response and returns the response in an array.
var x = reEntReq.responseText.lastIndexOf("ReportSession=");
var y = reEntReq.responseText.lastIndexOf("ControlID=");
var ret = new Array();
ret[0] = reEntReq.responseText.substr(x + 14, 24);
ret[1] = reEntReq.responseText.substr(x + 10, 32);
*This post is locked for comments
My suggestion - open reporting services instance and clarify all the details you need - report name, parameters e.t.c. Reports in reporting services contain all information you need.
Good luck.
Hi Andrew,
Sorry for my late response. You were right. I was using the wrong URL. So my server url looks something like this :
http://Server Name/ReportServer/ReportExecution2005.asmx
servername/.../ReportViewer.aspx
My report is the same as the blog post which you posted. It is a Quote Report which takes the Quote GUID. The second URL I mentioned is the final path of the report where I will enter the GUID of the Quote.
parameters[0].Value = string.Format("Select * From FilteredQuote Where QuoteId = '{0}'", context.PrimaryEntityId);
byte[] reportresult = rg.Render("/contoso_mscrm/quote", FormatType.PDF, parameters);
What should I do about the above two lines? Since it is taking in Quote ID , will the same query apply in my case as well?(Select * From FilteredQuote Where QuoteId = '{0})?
And this line - " byte[] reportresult = rg.Render("/contoso_mscrm/quote", FormatType.PDF, parameters)"? What should I be changing it to in my case? I mean I am confused about the path I need to enter.Can you think of what it might be in perspective of my server path and the report path I mentioned above? I would be needing it in a PDF Format.
Hello,
I believe you use wrong url during adding of web reference.
Take a closer look on following screenshot from my article - 4.bp.blogspot.com/.../93.png
ReportExecutionService _reportexecutionservice = null;
The above part. I believe you should be adding a web reference to the reporting web service? If I try to add it , I am thrown a " Object doesn't support addEventListener" error.
Currently my reports are in the URL, "organization url/crmreports/viewer/viewer.aspx?action=filter&helpID=Report Name &id=%7b ReportId %7d.
However, the JS function which am trying to mimic, has this URL referenced as report server : "Organization url/CRMReports/rsviewer/QuirksReportViewer.aspx";
The query it is executing is : "id=%7B" + reportGuid +
"%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName()
+ "&iscustomreport=true&reportnameonsrs=&reportName=" + reportName
+ "&isScheduledReport=false&p:QuoteId=" + reportPrefilter;
I am confused as to which URL I need to be using. I tried both the URLs and both are throwing me errors..I am currently on on -premise 2016. My reports are published for external use.
If you're onprem - what doesn't work when you try to use my article. I believe this one - butenko.pro/.../ms-crm-2011-general-approaches-to-generation-of-reports
Ok for trying to mimic the JS function ?
Mine is on premise only.
If you are online - you will not achieve that. If you're onprem - you're ok.
Hi Andrew,
I am trying to attach a PDF to a pre populated email. I am trying to follow the method mentioned in your blog. In order to do that, I need to add a web reference to
the report server? When I try to do that am thrown the error "Object doesn't support property or method 'addEventHandler'.
So I tried to mimic the JS method currently in the system. Looks like that would fail as well because of authentication?
Hi Venky,
Thanks for the response. What about this part?
var x = reEntReq.responseText.lastIndexOf("ReportSession=");
var y = reEntReq.responseText.lastIndexOf("ControlID=");
var ret = new Array();
ret[0] = reEntReq.responseText.substr(x + 14, 24);
ret[1] = reEntReq.responseText.substr(x + 10, 32);
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156