Cannot update Map using null index

Certified Senior Developer

HII  i am getting this error - Expression evaluation error [evaluation ID = NYEY6] in rule 'gai_displaybatchrecordsummary' at function a!gridField [line 59]: Cannot update Map using null index (APNX-1-4522-005)

How can i resolve this 

i have added my code 

a!gridField(
              showWhen: a!isNotNullOrEmpty(
                ri!record['recordType!{43099841-b468-444e-97af-bc369b79a6fc}GAI Batch.fields.{c835857e-c9ec-40d4-a818-f2d8593b1100}batchNumber']
              ),
              label: "Batch Details Grid",
              labelPosition: "COLLAPSED",
              data: a!recordData(
                recordType: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail',
                filters: a!queryLogicalExpression(
                  operator: "AND",
                  filters: {
                    a!queryFilter(
                      field: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{3cd6a92f-954f-48e2-84c9-a08a0d0228ad}gaiBatch.fields.{c835857e-c9ec-40d4-a818-f2d8593b1100}batchNumber',
                      operator: "=",
                      value: index(
                        ri!record,
                        'recordType!{43099841-b468-444e-97af-bc369b79a6fc}GAI Batch.fields.{c835857e-c9ec-40d4-a818-f2d8593b1100}batchNumber'
                      ),
                      applyWhen: a!isNotNullOrEmpty(ri!record)
                    )
                  }
                )
              ),
              columns: {
                a!gridColumn(
                  label: "Batch Number",
                  sortField: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{3cd6a92f-954f-48e2-84c9-a08a0d0228ad}gaiBatch.fields.{c835857e-c9ec-40d4-a818-f2d8593b1100}batchNumber',
                  value: fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{3cd6a92f-954f-48e2-84c9-a08a0d0228ad}gaiBatch.fields.{c835857e-c9ec-40d4-a818-f2d8593b1100}batchNumber'],
                  align: "START"
                ),
                a!gridColumn(
                  label: "Claim",
                  sortField: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.fields.{8fea466f-44f0-48d7-98be-9f7e56583544}claimName',
                  value: fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.fields.{8fea466f-44f0-48d7-98be-9f7e56583544}claimName'],
                  align: "START"
                ),
                a!gridColumn(
                  label: "Claim Status",
                  sortField: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.relationships.{26341cc8-db60-4bbd-a712-b158ecf829d6}gaiGrantWorkflow.relationships.{500684e3-be26-497b-b2f8-8bf57e1cf70a}gaiRefWorkflowTypeStatus.fields.{6dc4d2a3-05bc-40ce-a58b-e841a95486e0}workflowStatus',
                  value: fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.relationships.{26341cc8-db60-4bbd-a712-b158ecf829d6}gaiGrantWorkflow.relationships.{500684e3-be26-497b-b2f8-8bf57e1cf70a}gaiRefWorkflowTypeStatus.fields.{6dc4d2a3-05bc-40ce-a58b-e841a95486e0}workflowStatus'],
                  align: "START"
                ),
                a!gridColumn(
                  label: "Total Claim Amount",
                  sortField: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.fields.{956c8d95-2d88-4a76-ad4c-198073427f63}totalClaimAmt',
                  helpToolTip: "This is the amount claimed by the Grantee",
                  value: rule!SCO_getAmountInDollar(
                    fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.fields.{956c8d95-2d88-4a76-ad4c-198073427f63}totalClaimAmt']
                  ),
                  align: "END"
                ),
                a!gridColumn(
                  label: "Local Match Amount",
                  sortField: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.fields.{bcb56aa2-507e-44c6-a26f-9d1144aaf84f}localMatchAmt',
                  helpToolTip: "This is the amount that will be locally matched",
                  value: rule!SCO_getAmountInDollar(
                    fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.fields.{bcb56aa2-507e-44c6-a26f-9d1144aaf84f}localMatchAmt']
                  ),
                  align: "END"
                ),
                a!gridColumn(
                  label: "Claim Award Amount",
                  sortField: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.fields.{499bddaa-dfb2-4bf5-87ca-5b2f82e23180}fedAmt',
                  helpToolTip: "This is the amount that will be paid by " & cons!GAI_GRANTOR_NAME_ABBREVIATION,
                  value: a!richTextDisplayField(
                    value: {
                      a!richTextItem(
                        text: rule!SCO_getAmountInDollar(
                          fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.relationships.{ed0d4dd4-230c-4b55-b96c-cec86e9e1e40}gaiClaim.fields.{499bddaa-dfb2-4bf5-87ca-5b2f82e23180}fedAmt']
                        ),
                        style: { "STRONG" }
                      )
                    }
                  ),
                  align: "END"
                ),
                a!gridColumn(
                  label: "Update By",
                  sortField: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.fields.{eefd46b2-fc15-486f-a2fb-f5e2bcd72be5}updateUsr',
                  value: rule!GAI_utilFormatUserName(
                    fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.fields.{eefd46b2-fc15-486f-a2fb-f5e2bcd72be5}updateUsr']
                  )
                ),
                a!gridColumn(
                  label: "Update Date/Time",
                  sortField: 'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.fields.{a6d266a0-1b33-427c-aeef-e12137ed7185}updateTs',
                  value: if(
                    isnull(
                      fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.fields.{a6d266a0-1b33-427c-aeef-e12137ed7185}updateTs']
                    ),
                    fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.fields.{a6d266a0-1b33-427c-aeef-e12137ed7185}updateTs'],
                    datetext(
                      fv!row['recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.fields.{a6d266a0-1b33-427c-aeef-e12137ed7185}updateTs'],
                      "default"
                    )
                  ),
                  align: "START"
                )
              },
              pageSize: 50,
              validations: {},
              refreshAfter: "RECORD_ACTION",
              showSearchBox: true(),
              showRefreshButton: true,
              showExportButton: true,
              userFilters: {
                'recordType!{975fa1c0-6a6a-494c-bdf3-1b0d87ea07e0}GAI Batch Detail.filters.{669a0eb3-3ef4-4501-ae41-f03d0c668581}GAI Claim'
              }
            )

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer

    The error message you're encountering, "Cannot update Map using null index (APNX-1-4522-005)," indicates that there is an issue with the indexing of a map in your Appian expression. Specifically, it seems to be related to the use of an index on a map (dictionary) where the index is either null or undefined.

    Based on the code snippet you provided, I can see that you're trying to access fields within a record, and this error might be happening when attempting to access the following field:

    ```plaintext
    ri!record['recordType!{43099841-b468-444e-97af-bc369b79a6fc}GAI Batch.fields.{c835857e-c9ec-40d4-a818-f2d8593b1100}batchNumber']
    ```

    To resolve this issue, you should ensure that the `ri!record` variable is not null or empty before attempting to access its fields. You can do this using the `a!isNotNullOrEmpty()` function, which you've already used in your code.

    Here's how you can modify your code to handle this situation:

    ```a!gridField(
    showWhen: a!isNotNullOrEmpty(
    ri!record['recordType!{43099841-b468-444e-97af-bc369b79a6fc}GAI Batch.fields.{c835857e-c9ec-40d4-a818-f2d8593b1100}batchNumber']
    ),
    // ... rest of your code
    )
    ```

    By adding the `showWhen` condition, you ensure that the `a!gridField` is only displayed when the specified field in `ri!record` is not null or empty, which should prevent the "null index" error.

    Please make sure that you have also initialized the `ri!record` variable correctly before using it in this expression. If it's supposed to hold data, ensure it contains the necessary data before using it.

  • 0
    Certified Lead Developer
    in reply to hemanthkumar

    Please stop posting ChatGPT generated posts !!!