Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / The type 'Record' is n...
Finance forum
Suggested answer

The type 'Record' is not supported as a return value

Posted on by 136
Hi Team,
 
I have created new SSRS report, initial report is working fine.
 
I have created contract class and set return type is tmp table.
 
I am using DP, Contract and Controller class
 
Now, while run the report getting below error.
The type 'Record' is not supported as a return value.
 
Please let  me know how to solve this.
  • WV-08081158-0 Profile Picture
    WV-08081158-0 2 on at
    The type 'Record' is not supported as a return value
    Hi Martin,
     
    I was trying to create a data contract and have a list of classes attached to it.
     
    This is my SSRS report data contract:
     
    My Data contract containing the fields (which will be in the list):
     
    But when trying to execute, it returns me this error message: 
    Report parameters does not support collection of user defined class objects
     
    Coming from over here:
     
    So it looks like you cannot have a collection (like a List) of Classes as parameter for a Report data contract.
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 229,173 Most Valuable Professional on at
    The type 'Record' is not supported as a return value
    You never use your new class (TestDataContract), so it's the same as if you never created it.
     
    While creating a separate list for each field is technically possible, using such a solution is not particular easy. Using a list of objects (where each objects holds related values) it's much more natural. Let me give you an example, I'll just use more descriptive names to make it all easier to understand:
    [DataContract]
    class MainContract
    {
        List items;
        
        [
            DataMember,
            AifCollectionType('_items', classStr(ItemContract)),
            AifCollectionType('return', classStr(ItemContract))
        ]
        List parmItems(List _items = items)
        {
            items = _items;
            return items;
        }
    }
    
    
    [DataContract]
    class ItemContract
    {
        str field1;
        int field2;
        str field3;
    
        [DataMember('Field1')]
        public str parmField1(str _field1 = field1)
        {
            field1 = _field1;
            return field1;
        }
    
        [DataMember('Field2')]
        public int parmField2(int _field2 = field2)
        {
            field2 = _field2;
            return field2;
        }
    
        [DataMember('Field3')]
        public str parmField2(str _field3 = field3)
        {
            field3 = _field3;
            return field3;
        }
    }
     
  • Suggested answer
    GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    The type 'Record' is not supported as a return value
    Hi,
     
    You cannot use the table as return type for the SSRS report contract class - You can only use data types.
    You need to rethink your design - I would suggest you to use List type for your scenario.
     
    Thanks,
    Girish S.
  • CU21091228-0 Profile Picture
    CU21091228-0 136 on at
    The type 'Record' is not supported as a return value
    Hi Martin.
     
    I need  a collection of such records
    I am sharing some sample code please let me know if i am wrong.
    New TestDataContract class with three different fields.
    [DataContractAttribute]
    class TestDataContract
    {
        Field1 field1;
        Field2 field2;
        Field3 field3;
    
        [DataMemberAttribute('Field1')]
        public Field1 parmField1(Field1 _field1 = field1)
        {
            field1 = _field1;
            return field1;
        }
    
        [DataMemberAttribute('Field2')]
        public Field2 parmField2(Field2 _field2 = field2)
        {
            field2 = _field2;
            return field2;
        }
    
        [DataMemberAttribute('Field3')]
        public Field3 parmField2(Field3 _field3 = field3)
        {
            field3 = _field3;
            return field3;
        }
    
    }
    Created list for all three fields.
     
    [DataContractAttribute]
    class TestReportContract
    {    
       List field1, field2, field3;   
     
      [DataMemberAttribute('Field1'),
      AifCollectionTypeAttribute('return', Types::String)]    
      public List parmListField1(List _field1 = field1)    
      {        
          field1 = _field1;    
          return field1;   
      }
    
      [DataMemberAttribute('Field2'),
      AifCollectionTypeAttribute('return', Types::Int)]    
      public List parmListField2(List _field2 = field2)    
      {        
          field2 = _field2;    
          return field2;   
      }
    
      [DataMemberAttribute('Field3'),
      AifCollectionTypeAttribute('return', Types::String)]    
      public List parmListField3(List _field3 = field3)    
      {        
          field3 = _field3;    
          return field3;   
      }
    }
     
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 229,173 Most Valuable Professional on at
    The type 'Record' is not supported as a return value
    The short answer is "don't use a table".
     
    The longer answer is: how to solve it depends on what you're trying to achieve. If you inserted several records to a temporary buffer and you want to somehow pass the reference, it can't work. The report may run on a different machine, weeks later and so on, so you can't refer to any temporary buffer, because it doesn't have to exist anymore.
     
    If you want a single set of fields, add them to your TestReportContract class directly. If you need a collection of such records, create a new data contract for those values and add a List of those contracts as a data member of TestReportContract.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,867 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,173 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans