locked
Report Custom Code in CRM 2011 Online RRS feed

  • Question

  • I cannot upload a report RDL file containing custom code (VB code) in a CRM 2011 online environment. I can only get reports with custom code to upload into a CRM 2011 local environment. Even the following simple example custom code causes a report import failure, (I found the code at http://bryantlikes.com/WritingCustomCodeInSQLServerReportingServices.aspx): CUSTOM CODE: Public Function SayHello() as String Return "Hello from Embedded Code" End Function CALLED BY THE FOLLOWING EXPRESSION: =Code.SayHello() I even tried condensing the function down to one line of code, adding new lines between each line of code, and so forth...and it still failed. I have not found any mention in the SDK as to whether custom code is supported or not in CRM Online.
    • Edited by RST Dev Wednesday, March 16, 2011 11:19 PM
    Wednesday, March 16, 2011 9:56 PM

Answers

  • CRm 2011 restrict CODE element in the reports. CRM 2011 use SSRS sandboxing to restrict the code element.

    Try using the expression to achieve the functionality.

     

    Thanks

    Kunal

    Thursday, March 17, 2011 6:18 AM
  • @Frank: You should be able to achieve what you want using LookupSet function of SSRS 2008 R2 (which we use in CRM Online) as described below. For more details, see LookupSet function.

    =Join(LookupSet(1, 1, Fields!AccountName.Value, "DataSet1"), ",")

     

    @RST Dev: Although RDL sandboxing makes the RDL quite restrictive, it is still very powerful and should enable a lot of scenarios. In cases where it cannot achieve what you are looking for, you may be able to define custom fields on entities and have them populated using sandboxed plugins in CRM 2011. Then these custom fields can be used on the reports just like any other field. HTH.

    Thanks


    Abhishek Agarwal MSFT
    Thursday, March 17, 2011 5:30 PM

All replies

    • Marked as answer by Donna EdwardsMVP Wednesday, March 23, 2011 6:35 PM
    • Unmarked as answer by RST Dev Thursday, June 23, 2011 10:08 PM
    Wednesday, March 16, 2011 10:06 PM
    Moderator
  • Here is my post in a more coherent format.  During submission, the tabs and spaces were apparently ignored in my original post.

    ***************************************************************************

    Custom Code:

    Public Function SayHello() as String
     Return "Hello from Embedded Code"
    End Function
    
    SSRS Expression:

     

    =Code.SayHello()
    I cannot upload a report RDL file containing custom code (VB code) in a CRM 2011 online environment. I can only get reports with custom code to upload into a CRM 2011 local environment. Even the simple example custom code causes a report import failure.  I even tried condensing the function down to one line of code, adding new lines between each line of code, and so forth...and it still failed. I have not found any mention in the SDK as to whether custom code is supported or not in CRM Online.

     

     

     

     

    Wednesday, March 16, 2011 11:36 PM
  • CRm 2011 restrict CODE element in the reports. CRM 2011 use SSRS sandboxing to restrict the code element.

    Try using the expression to achieve the functionality.

     

    Thanks

    Kunal

    Thursday, March 17, 2011 6:18 AM
  • Hi Kunal,

     

    Is it possible with expression to string a result set together?

    For example:

    From fetchxml:
    list value 1
    list value 2

    Present it like "list value 1, list value 2, etc.."

     


    Follow Workopia on Twitter

    Good CRM Links: http://www.workopia.com/Links.htm
    My CRM Blog: http://microsoft-crm.spaces.live.com

    Thursday, March 17, 2011 8:44 AM
    Moderator
  • Frank,

    I didn't quiet get your question completly. Do you intend to concatenate 2 field valued from the fetch xml? If yes, yes it would be possible by using string.format().

    Also expression in rdl are very similar to the vb function and you can use many vb function defined (unless they are restricted by us in the sandboxing file). If you wish we can pass on to the function restricted/Allowed there.

     

    Thanks

    Kunal

    Thursday, March 17, 2011 9:58 AM
  • Thanks Kunal,

    It is more like the same field but different rows.  I would like to concatenate the rows into a string for report presentation.

    Account Name field:

    ABC
    123
    XYZ

    >> Account Names: ABC, 123, XYZ

    It is pretty easy if we can use code, but for CRM Online with sandbox mode - like to find a workaround.  Hope that clarify it. 


    Follow Workopia on Twitter

    Good CRM Links: http://www.workopia.com/Links.htm
    My CRM Blog: http://microsoft-crm.spaces.live.com

    Thursday, March 17, 2011 10:05 AM
    Moderator
  • If CRM Online always has RDL Sandboxing enabled, then it is certain that CRM Online does not support custom code (Visual Basic) embedded in report RDLs. I am not exactly sure how big of a limitation this is, but my suspicion is that it is a pretty big one. More information about RDL sandboxing can be found here: http://msdn.microsoft.com/en-us/library/ee210591.aspx
    Thursday, March 17, 2011 1:52 PM
  • @Frank: You should be able to achieve what you want using LookupSet function of SSRS 2008 R2 (which we use in CRM Online) as described below. For more details, see LookupSet function.

    =Join(LookupSet(1, 1, Fields!AccountName.Value, "DataSet1"), ",")

     

    @RST Dev: Although RDL sandboxing makes the RDL quite restrictive, it is still very powerful and should enable a lot of scenarios. In cases where it cannot achieve what you are looking for, you may be able to define custom fields on entities and have them populated using sandboxed plugins in CRM 2011. Then these custom fields can be used on the reports just like any other field. HTH.

    Thanks


    Abhishek Agarwal MSFT
    Thursday, March 17, 2011 5:30 PM
  • Thanks Abhishek, 2008 R2 Expression works great!
    Follow Workopia on Twitter

    Good CRM Links: http://www.workopia.com/Links.htm
    My CRM Blog: http://microsoft-crm.spaces.live.com

    Saturday, March 26, 2011 5:21 AM
    Moderator
  • Hi Team,

    I have written the below code to calculate the distinct opportunities total estimates value in SSRS and its working fine in SSRS but when i upload the RDL, CRM online is not accepting the file as it has the code.

    Dim IDs() As System.Collections.Hashtable=New System.Collections.Hashtable(15) {}

     

    Dim totals() as Double = New Double(15) {}

    DIm Grps as System.Collections.Hashtable

    Dim i as integer

     

    Function DistinctSum(sGrp as String, ID As Object) As Boolean

            If (Grps is nothing) Then

                Grps = New System.Collections.Hashtable

            End if

            If (Not Grps.Contains(sGrp)) Then

                    i=Grps.Count+1

                    Grps.Add(sGrp, i)

            Else

                    i=Grps.Item(sGrp)

            End If

            If (IDs(i) Is Nothing) Then

                IDs(i) = New System.Collections.Hashtable

            End If

            If (ID Is Nothing) Then

                DistinctSum= "False"

            Else

                If (Not IDs(i).Contains(ID)) Then

                    IDs(i).Add(ID, 0)

                    DistinctSum= "True"

                Else

                    DistinctSum= "False"

               End If

            End If

    End Function

     

    Can anyone please suggest me an alternative for this?


    Ravishankar Polepalli (MCP)
    Microsoft Dynamics, Project Server and SharePoint Server Consultant
    ravi.polepalli@gmail.com
    Sunday, November 27, 2011 8:15 AM
  • Hi Abishek, I have a similar issue, where I just need to display the record row number (as the DataSet returns the number of records) in the table? It will be a simple code if I can use the VB. ie 

    Dim I as integer 

    public Function RowNumber()

    i = i+1

    return i

    End Function

     

    No	Description	Amount
    1	Item 1	$250
    2	Item 2	$360
    		
    N	Item N	Item Nth Amount 
    

    I will call the =code.RowNumber() from the table text box expression. But Can you show me an example of how LookUpSet will work. I try to follow the example but am lost. 

     


    • Edited by CRM elite Thursday, February 2, 2012 1:21 AM
    Thursday, February 2, 2012 1:20 AM
  • HI kunal,

    are you able to connect online crm 2011 via BIDS. I tried may possible way not get success.

    Is it possible or not.


    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Saturday, August 31, 2013 4:34 AM