Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Liam Prowse 6 posts 76 karma points
    Jul 15, 2021 @ 11:00
    Liam Prowse
    0

    IRecordReaderService causing null reference exception

    Hey everyone

    I am using the IRecordReaderService and GetRecordsFromForm(), however, whenever it gets called, it returns a null reference error, I am 100% passing in the correct form Id, it was working a month ago when I wrote the functionality, I'm using Umbraco 8.14 and Umbraco Forms 8.7.1.

    Any help would be appreciated :)

    My code is as below:

    var guid = Guid.Parse(model.FormId);
    
            PagedResult<IRecord> AllRecords = _recordReaderService.GetRecordsFromForm(guid, 1, 10);
    

    the error I'm getting is below

    [NullReferenceException: Object reference not set to an instance of an object.]
    

    Umbraco.Forms.Core.Services.RecordReaderService.GetRecordsFromForm(Guid formId, Int32 pageNumber, Int32 pageSize) +87 Demelza.Controllers.Authorized.FormsExportController.ExportSingleFormAsPdf(FormExportModel model) in C:\Repos\Demelza\Demelza\Demelza\Controllers\Authorized\FormsExportController.cs:42 lambdamethod(Closure , ControllerBase , Object[] ) +138 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +34 System.Web.Mvc.Async.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +38 System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +76 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +41 System.Web.Mvc.Async.<>cDisplayClass110.

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Jul 27, 2021 @ 21:30
    Nik
    0

    Hi Liam,

    Did you ever get to the bottom of this? Taking a guess, has the form been modified, either a field removed, or a new one added? If so that could be causing your issue.

    Nik

  • Liam Prowse 6 posts 76 karma points
    Jul 28, 2021 @ 07:56
    Liam Prowse
    0

    I didn't, I have time booked in this week to investigate it further and maybe find another way of doing it, but it happens with any form, new or old, it's really strange

  • Paul 4 posts 93 karma points
    Apr 28, 2023 @ 15:12
    Paul
    0

    have you injected IRecordReaderService into your constructor?

Please Sign in or register to post replies

Write your reply to:

Draft