Copied to clipboard

Flag this post as spam?

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


  • Kenny Burns 172 posts 302 karma points
    1 week ago
    Kenny Burns
    0

    Umbraco forms - Export Type

    Hello,

    I am following this documentation to add a custom Umbraco form export:

    https://our.umbraco.com/documentation/add-ons/umbracoforms/developer/Extending/Adding-a-Exporttype

    However when i call: _formRecordSearcher.QueryDataBase(filter)

    I am getting a user null ref error: Value cannot be null. Parameter name: user

    at Umbraco.Core.Models.UserExtensions.HasAccessToSensitiveData(IUser user) in d:\a\1\s\src\Umbraco.Core\Models\UserExtensions.cs:line 202

    It seems like maybe some sort of permission issue or it doesnt have the umbraco context for security? Anyone have any ideas?

    Cheers

    Kenny

  • Kenny Burns 172 posts 302 karma points
    1 week ago
    Kenny Burns
    0

    For anyone who might come across this....

    In my service before I called _formRecordSearcher.QueryDataBase(filter) I had to insert the line:

    HttpContextBase wrapper = new HttpContextWrapper(HttpContext.Current);
    UmbracoBackOfficeIdentity user = wrapper.GetCurrentIdentity(true);
    

    ...which i guess forces the user identity.

    Also, for the filter model passing in, it looked something like this:

    RecordExportFilter recordExportFilter = new RecordExportFilter
                {
                    StartDate = request.DateFrom,
                    EndDate = request.DateTo,
                    Form = new Guid(request.FormGuid),
                    SortOrder = RecordSorting.Descending,
                    SortBy = "Created",
                    ExportType = "",
                    Filter = "",
                    LocalTimeOffset = -120,
                    StartIndex = 1,
                    Length = 0,
                    States = new List<FormState>()
                };
    
Please Sign in or register to post replies

Write your reply to:

Draft