Improvement of the Cases Component JSON output

Currently, the Cases Module component has two options when selecting the View Type, “List” and “Detail”. Any time I have pulled the data, the JSON output is the same on both. (Might be different in some situations I have not used.) I bring this up because I have encountered a few issues while trying to display case data on the front end.

  • The Data is hard to display in a simple table or layout without added liquid. As illustrated here. Cases Data Component Output Order Issue - #3 by Rhatch
  • The data is not always in the same order.
  • This could become a resource issue with large amounts of data.
  • When you export the data, the columns do not align with the order of the from properties, as they do in a custom module. (my OCD)
  • There is no way to filter from the component tag any custom form fields or system form fields.
  • There is no way of sorting from the component tag any custom form fields or system form fields.

Suggestion: Leave the View Type: “Detail” layout as is and change the “List” to output like a custom module.

Here is a sample of the “Detail” layout as found in the docs. cases

{
    "Items": [
        {
            "FormName": "DEMO AJAX Example reCaptcha v3",
            "DateSubmission": "2021-08-24T20:20:20.618268",
            "CreatedDateTime": "2021-08-24T20:20:20.618268",
            "Id": "4598",
            "Fields": [
                {
                    "Name": "First Name",
                    "Alias": "FirstName",
                    "Type": "String",
                    "Value": "Alex",
                    "ArrayValue": [
                        "Alex"
                    ]
                },
                {
                    "Name": "Last Name",
                    "Alias": "LastName",
                    "Type": "String",
                    "Value": "Smith",
                    "ArrayValue": [
                        "Smith"
                    ]
                }
            ],
            "FormId": "1387",
            "OrderId": "0",
            "MemberId": "1442"
        }
    ],
    "Params": {
        "type": "cases",
        "collectionvariable": "allCases",
        "layout": "",
        "filterby": "MemberId",
        "filtervalue": "1442",
        "limit": "3",
        "viewtype": "list"
    }
}

I propose that the “List” be structured similarly to most other modules. Shown here in the docs. Component Type: Module (Custom Modules)
Basically, removing the Fields array and bringing the needed data forward.

{
    "Items": [
        {
            "FormName": "DEMO AJAX Example reCaptcha v3",
            "DateSubmission": "2021-08-24T20:20:20.618268",
            "CreatedDateTime": "2021-08-24T20:20:20.618268",
            "Id": "4598",
            "FirstName": "Alex",
            “LastName": "Smith",
            "FormId": "1387",
            "OrderId": "0",
            "MemberId": "1442"
        }
    ],
    "Params": {
        "type": "cases",
        "collectionvariable": "allCases",
        "layout": "",
        "filterby": "MemberId",
        "filtervalue": "1442",
        "limit": "3",
        "viewtype": "list"
    }
}

Hopefully this makes sense. Would like to hear what other think and how they are using this module.

Another possibility is to structure the JSON in the same way the FormSubmissionData object is [{{ formSubmissionData }} object], so we have both ways of addressing the data (either looping through all fields indiscriminately, or able to target fields by name) but still including all extra field data such as input type and array values.
This would bring the cases module output inline with FormSubmissionData, which I think would make sense to do.

eg:

{
    "submissionid": 123,
    "form_name": "DEMO Contact Form",
    "form_alias": "demo_contact_form",
    "fields": {
        "system": {
            "firstname": {
                "id": "FirstName",
                "name": "First Name",
                "value": "Alex"
            },
            "lastname": {
                "id": "LastName",
                "name": "Last Name",
                "value": "Smith"
            },
            "email": {
                "id": "Email",
                "name": "Email",
                "value": "asmith@example.com"
            },
            "phone": {
                "id": "Phone",
                "name": "Phone",
                "value": "11222333444"
            }
        },
        "custom": {
            "enquiry": {
                "id": "Enquiry",
                "name": "Enquiry",
                "value": "Hi. This is a test message."
            }
        },
        "all": [
            {
                "id": "FirstName",
                "name": "First Name",
                "value": "Alex"
            },
            {
                "id": "LastName",
                "name": "Last Name",
                "value": "Smith"
            },
            {
                "id": "Email",
                "name": "Email",
                "value": "asmith@example.com"
            },
            {
                "id": "Phone",
                "name": "Phone",
                "value": "11222333444"
            },
            {
                "id": "Enquiry",
                "name": "Enquiry",
                "value": "Hi. This is a test message."
            }
        ]
    },
    "error": 0,
    "errormessages": [],
    "crmcontactlink": "https://docs.webinone.com/admin/contacts/17",
    "crmformsubmissionlink": "https://docs.webinone.com/admin/form-submissions/150",
    "crmEventBookingLink": "https://docs.webinone.com/admin/event-bookings/3",
    "formtype": "Generic"
}

This, however, does not address the issue of being able to filter and sort the component by field values.

1 Like