0

I am struggeling with a DataEntity that is created from a view. The scenario is that the entity will be used by PowerBI via the "/data" url from a d365 instance. When the entity is requested and the json should be generated nothing happens. When i opened the WebDeveloperTools from my browser and i requested the url for this entity i got the following error:

    {
  "error":{
    "code":"","message":"An error has occurred.","innererror":{
      "message":"The given model does not contain the type 'Microsoft.Dynamics.Ax.Xpp.EdtArray`1[System.Decimal]'.",
      "type":"System.InvalidOperationException",
      "stacktrace":"   at System.Web.OData.Formatter.Serialization.ODataSerializerContext.GetEdmType(Object instance, Type type)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateStructuralProperty(IEdmStructuralProperty structuralProperty, EntityInstanceContext entityInstanceContext)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateStructuralPropertyBag(IEnumerable`1 structuralProperties, EntityInstanceContext entityInstanceContext)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateEntry(SelectExpandNode selectExpandNode, EntityInstanceContext entityInstanceContext)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(Object graph, ODataWriter writer, ODataSerializerContext writeContext)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataFeedSerializer.WriteFeed(IEnumerable enumerable, IEdmTypeReference feedType, ODataWriter writer, ODataSerializerContext writeContext)\r\n   
                       at System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content, HttpContentHeaders contentHeaders)\r\n   
                       at System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n
                       --- End of stack trace from previous location where exception was thrown ---\r\n   
                       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
                       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__24.MoveNext()\r\n
                       --- End of stack trace from previous location where exception was thrown ---\r\n   
                       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
                       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Owin.HttpMessageHandlerAdapter.<BufferResponseContentAsync>d__13.MoveNext()"
    }
  }
}

What does this mean and more importantly how can i avoid this ?

the datasource is a view called 'TSTimesheetSummaryLine'. i copyied another entity, removed everything from it, dropped the view as datasource and then dragDropped all fields from datasource to the fields of the entity

I noticed that the view does contain a real-array (hours)

D.J.
  • 3,644
  • 2
  • 15
  • 22
  • Does the view contain array/decimal fields? What happens when you remove those fields? – FH-Inway Mar 14 '19 at 16:27
  • @FH-Inway it contains decimal fields, but no array fields. the datasource also doesn't contain array fields, the datasource of the datasource contains an array but that isn't used. The datasource also has some calculated fields but none of them are an array so i am very confused from where this might come from. the datasource is a view called 'TSTimesheetSummaryLine'. i copyied another entity, removed everything from it, dropped the view as datasource and then dragDropped all fields from datasource to the fields of the entity – D.J. Mar 14 '19 at 16:40
  • 1
    Ok, sounds easy enough to reproduce. I will let you know my results when I find the time to do it. In the meantime, you may want to [edit] the information from your comment into the question and add which exact version of D3FO you are own exactly while you are at it. This will make it easier for others to get the relevant information about your question and maybe provide an answer earlier than I can. – FH-Inway Mar 14 '19 at 20:01
  • 1
    @FH-Inway i updated the question. when reviewing the stuff after a while i noticed that the view DOES contain a real-array (hours) – D.J. Mar 22 '19 at 08:43

1 Answers1

1

Appearantly real-arrays can be used in views but not in entities. The field that was causing this exception was "hours", it stores 7 real values (one for each day of week).

Solution:

I set the access-modifier of "hours" on the dataEntity to "Internal", added fields for each value ("Hours1" to "Hours7") and set the values for theese fields from the array in the "OnPostingLoad"-EventHandler of the dataEntity

D.J.
  • 3,644
  • 2
  • 15
  • 22
  • 1
    Correct, OData does not support array fields, see [Open Data Protocol](https://learn.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/odata#array-fields) (Odata), section "Array fields". Also take a look at [How to add new field of Array Element Extended data type to extension entity](https://community.dynamics.com/365/financeandoperations/f/765/t/298023), the answer by Deepak Kumar on December 4th 2018 suggests that newer versions might support it. – FH-Inway Mar 22 '19 at 15:36