Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Use DocuRefEntity to access attachments for Cases

(0) ShareShare
ReportReport
Posted on by

Hello,

I have created a public data entity XXXCaseDetailAttachments with DocuRefEntity as main data source and CaseDetailBase table as child data source to enable access of attachment cases via OData.

pastedimage1674568501885v4.png
I have tried to export via data management but I am having the following error:

pastedimage1674568156013v1.png

Value cannot be null
Parameter name: location

It is not working via OData as well:
pastedimage1674568272653v2.png

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage/>
<ExceptionType>Microsoft.Dynamics.Ax.Xpp.ClrErrorException</ExceptionType>
<StackTrace> at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue, interpret* ip) at Microsoft.Dynamics.Ax.MSIL.cqlCursorIL.NextRec(IntPtr table) at Microsoft.Dynamics.Ax.Xpp.Common.NextRec() at Microsoft.Dynamics.AX.Framework.Linq.Data.Msil.AxRecord.MoveNext() at Microsoft.Dynamics.AX.Framework.Linq.Data.AxProjectionReader`1.Enumerator.MoveNext() at Microsoft.Dynamics.Platform.Integration.Services.OData.Query.QueryEvaluator.Evaluate(IQueryable query, IServicesRequestSessionProvider servicesRequestSessionProvider, IODataSecurityRights securityRights) at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataController.Get() at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Tracing.Tracers.HttpControllerTracer.<ExecuteAsyncCore>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()</StackTrace>
</Error>

However, there are records in the data entity when doing a select in SQL:

pastedimage1674568382062v3.png

Has anyone had this issue and if you could please help me out?

Thanks.

  • Suggested answer
    Jason0810M Profile Picture
    Jason0810M on at
    RE: Use DocuRefEntity to access attachments for Cases

    Hello,

    I have found the issue. The method call postLoad in DocuRefEntity gets fileContents of the DocuRef record. The problem is that the database on the dev machine originates from another UAT environment and therefore attached files of the records are not found. The method call to retrieve the file contents generates an exception in such a case. I have implemented the logic within a try-catch to set the value of the fileContents to null in case of exception generated upon the method call to retrieve file contents.

  • Jason0810M Profile Picture
    Jason0810M on at
    RE: Use DocuRefEntity to access attachments for Cases

    Hello Martin,

    Thanks for your build suggestion.

    I think this is probably due to a build compilation issue as I have noticed an error stating 'Datasource CustInvoiceTrans_W is not found in view TaxTransDeclarationDetailsView'. I think that's what causing this error for the data entity. Weirdly enough, there is a method call to CustInvoiceTrans_W in the view but the datasource cannot be found in the designer view.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Use DocuRefEntity to access attachments for Cases

    All right, we've solved nothing but we at least have an easier way to debug it.

    I would recompile the package and synchronized DB once more before investigating it further.

  • Jason0810M Profile Picture
    Jason0810M on at
    RE: Use DocuRefEntity to access attachments for Cases

    Hello Bharani,

    Yes, I have tried in SSMS and the records are the same.

  • Jason0810M Profile Picture
    Jason0810M on at
    RE: Use DocuRefEntity to access attachments for Cases

    Hello Martin,

    It generates the same error as exception while executing the while statement:

    Microsoft.Dynamics.Ax.Xpp.ClrErrorException at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue, interpret* ip) at Microsoft.Dynamics.Ax.MSIL.cqlCursorIL.NextRec(IntPtr table) at Microsoft.Dynamics.Ax.Xpp.Common.NextRec() at Dynamics.AX.Application.Test.`main(Args _args) in xppSource://Source/XXX\AxClass_Test.xpp:line 8 at Dynamics.AX.Application.Test.main(Args _args) at Test::Main(Object[] , Boolean& ) at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters) at Dynamics.AX.Application.SysClassRunnerHelper.`runMainMethod(SysClassRunnerState state) in xppSource://Source/ApplicationFoundation\AxClass_SysClassRunnerHelper.xpp:line 30 at Dynamics.AX.Application.SysClassRunnerHelper.runMainMethod(SysClassRunnerState state) at Dynamics.AX.Application.Forms.SysClassRunner.FormControl.timerControl.elapsed() in xppSource://Source/ApplicationFoundation\AxForm_SysClassRunner.xpp:line 52

    Value cannot be null. Parameter name: location

  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Use DocuRefEntity to access attachments for Cases

    Have you tried giving the same relation in SSMS? Is it returning all the required records?

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Use DocuRefEntity to access attachments for Cases

    I would try one more thing. What happens if you try to iterate records in a runnable class?

    XXXCaseDetailAttachmentsEntity attachment;
    
    while select attachment
    {
    }

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans