locked
How to get the Report ID using its name RRS feed

  • Question

  • Hi All,

    I have created a SSRS report and uploaded into the CRM called (PreintPreview.rdl). From the Print Preview button of a form I need to pass this Report's id to the Javascript function called RunReport.

    How can I get the Id (32 char long) using Report's name at run time in Javascript?

    Thanks in advance

     

    Regards

    Jhelumi786

     

     

    Friday, April 16, 2010 10:34 AM

Answers

All replies

  • The entity is 'report' and the field name is 'name'. 'name' is the report name iin CRM not the rdl filename.

    So use this http://consulting.ascentium.com/blog/crm/Post129.aspx orhttp://danielcai.blogspot.com/2010/01/crm-web-service-javascript-toolkit.html by either using the framework they provide or just take the RetrieveMulitple function code.


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Friday, April 16, 2010 10:48 AM
    Moderator
  • Hi RhettClinton,

    Thanks for the response. I'm trying to use the following trick.

    http://adrian-alexan.blogspot.com/2009/12/customizing-entities-print-preview-form.html

    The RunReport() function is as follow:-

    /**********************************************/

     

    function RunReport(bInstance, sName, sUrlPrefix, iReportType, sHelpId)

    {

    var oWindowInfo = GetWindowInformation(Report);

    if (bInstance)

    {

    var sUrl = sUrlPrefix + prependOrgName("/") + oWindowInfo.Url + "?action=run&id=" + CrmEncodeDecode.CrmUrlEncode (sName)

    + (bInstance ? "&context=records&recordstype=" + getOTC() + "&records=" + CrmEncodeDecode.CrmUrlEncode(getID()) : "")

    + "&helpID=" + sHelpId;

    openStdWin (sUrl, buildWinName(), oWindowInfo.Width, oWindowInfo.Height);

    }

    else

    {

    ViewReport (iReportType, sUrlPrefix, sName, sHelpId, "run");

    }

    }

    /********************************************/

     

    Now if I pass the function the Name of the report ("PrintPreview") as 2nd parameter, i get the error that Id should be 32 digit.

    If I change that with the Id of the value {0F0941D7-AC35-DF11-A489-00065BF78156} it works perfect.

    What I want is to get this id value using report name. I don't want to screw the original code as this function is used by some other locations as well I believe.

    I think that guy means to put the Id of the Report instead of name in his trick example. I tried to contact him but without success.

     

    Regards

    Jhelumi786

    Friday, April 16, 2010 11:30 AM
  • you can get this value from report server..login to report server as follows..

    step1 : type http://<<CRM DATABASE SERVER NAME>>/reports in IE

    Step2 : Click on Show Details button on right hand corner and this will display all crm organisation

    Step3 : click on your Organisaiton and then click on "4.0" folder

    Step4 : this will list down all crm reports with it's guid ..search for your one and use the details as per your requirement..

    Hope this helps..

    Friday, April 16, 2010 12:36 PM
  • As Rhett has suggested, you may use CRM Web Service Toolkit to do the job, here is the script that I came up:

    getReportId = function(reportName)
    {
    	var fetchXml = [
    "<fetch mapping='logical'>",
     "<entity name='report'>",
     "<attribute name='reportid' />",
     "<filter>",
      "<condition attribute='name' operator='eq' value='", reportName, "' />",
     "</filter>",
     "</entity>",
    "</fetch>"
     ].join("");
    
    	var result = CrmServiceToolkit.Fetch(fetchXml);
     if (result === null) {
     throw new Error("Report " + reportName + " cannot be found. "); // This should never happen if the report exists
     }
     
     return result[0].getValue("reportid");
    };

    Call it by passing your report's name as the single parameter such as this: 

    getReportId("Quote")

     

    Hope this helps. 


    Daniel Cai | http://danielcai.blogspot.com
    Friday, April 16, 2010 2:21 PM
  • Yes, as Daniel has pretty much given you the entire solution you can use this to the get the id and pass into your RunReport function. This is more flexible then hard coding the id of the report in your code as moving from dev to live you can bet the id will be different.


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Friday, April 16, 2010 3:03 PM
    Moderator
  • Thanks Guys,

    I'm trying that but having issues on installing the crmServiceToolkit.

    Although I copied all the said files in the folder crmServiceToolkit under ISV Folder and reset the iis as well but still getting the error

    CrmServiceToolkit not found

     

     

    Friday, April 16, 2010 3:10 PM
  • You may simply copy the content of CrmServiceToolkit.js file to your form's OnLoad event. 
    Daniel Cai | http://danielcai.blogspot.com
    Friday, April 16, 2010 3:13 PM
  • Thanks Everyone.

    Its seems to be working perfectly. 

    Thanks once again for making my weekend good.

    Friday, April 16, 2010 3:49 PM
  • Glad to know it worked. You might want to mark Rhett's response as answer as well, he responded with valid answer at the first place. ;)

    Have a nice weekend.


    Daniel Cai | http://danielcai.blogspot.com
    Friday, April 16, 2010 3:54 PM
  • U r absolutely right . 

    Have a nice weekend

    Cheers

     

    Friday, April 16, 2010 4:15 PM
  • Cheers


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Friday, April 16, 2010 7:18 PM
    Moderator