I am getting this error,"Interface Definition: Expression evaluation error [evaluation ID = c6a1e:375c5] : An error occurred while executing a save: java.lang.IllegalArgumentException: Invalid index type: Cannot index property '1' into diction

Certified Associate Developer

a!localVariables(
  local!transaction: index(
    rule!NW_getTransactionDataFromKongAPI(transactionId: ri!transactionId),
    1,
   {}
  ),
  {
    a!cardLayout(
      contents: {
        a!richTextDisplayField(
          value: {
            a!richTextItem(
              text: cons!NW_TXT_QUICK_ACTION_CASE_TYPE_UPDATE_SUITABILITY_STATUS,
              color: cons!NW_COLOR_WHITE,
              size: "MEDIUM_PLUS",
              style: "STRONG"
            )
          }
        )
      },
      height: "EXTRA_SHORT",
      style: cons!NW_COLOR_PRIMARY,
      marginBelow: "STANDARD"
    ),
    a!cardLayout(
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!dropdownField(
                  label: "Suitability Status",
                  labelPosition: "ADJACENT",
                  required: true(),
                  placeholder: "------Select Suitability Status from the below List----",
                  choiceLabels: {
                    "Approved",
                    "NC Non-Suitability Not Taken-HO Decision",
                    "NC Suitability Not taken-HO Decision",
                    "Non-Suitability Decline",
                    "Not Taken",
                    "Partial Approve",
                    "Pending",
                    "Suitability Decline"
                  },
                  choiceValues: {
                    "Approved",
                    "NC Non-Suitability Not Taken-HO Decision",
                    "NC Suitability Not taken-HO Decision",
                    "Non-Suitability Decline",
                    "Not Taken",
                    "Partial Approve",
                    "Pending",
                    "Suitability Decline"
                  },
                  value: local!transaction.suitability.decision_results[1].outcome,
                  saveInto: local!transaction.suitability.decision_results[1].outcome,
                  
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!dropdownField(
                  label: "Decline Reasons",
                  required: true(),
                  labelPosition: "ADJACENT",
                  placeholder: "------Select Decline Reason from the below List----",
                  choiceLabels: {
                    "Advantages",
                    "CA Medi-Cal",
                    "CA Surrender Charges",
                    "Death Benefit Loss",
                    "Disability",
                    "Disadvantages",
                    "Does your Income cover all living expenses including medical",
                    "Do you have an emergency fund",
                    "High Annuity to net worth ratio",
                    "High Fixed Rate",
                    "Income Rider Loss",
                    "Income Rider VS Income Rider",
                    "Insufficient Replacement Reason",
                    "Internal Replacement Guidelines",
                    "I refuse",
                    "Is Not Based",
                    "Is your Income sufficient to cover future changes",
                    "Limited",
                    "Low Disposable Income",
                    "Low Liquid Assets",
                    "MN Recommendation Unsupported",
                    "MN Replacement not out of surrender term",
                    "MO Lookback",
                    "Nationwide under 36 months",
                    "Non-Resident",
                    "Non-US Funds",
                    "NY-Producer doesn't feel fixed annuity is in the customer's best interest",
                    "NY-Producer Limitations on products offered",
                    "NY-Producer feels product isn't in the customer's best interest",
                    "NY-Understanding of non-guaranteed elements",
                    "NY Reg60",
                    "NY Surrender Charges",
                    "Product Availability",
                    "Replacement prior to anniversary date",
                    "Replacement under 12 months",
                    "Replacement under 24 months",
                    "Reverse Mortgage",
                    "Suitability Client Call Issues",
                    "Surrender Charges",
                    "Unemployment",
                    "Watch Producer"
                  },
                  choiceValues: {
                    "Advantages",
                    "CA Medi-Cal",
                    "CA Surrender Charges",
                    "Death Benefit Loss",
                    "Disability",
                    "Disadvantages",
                    "Does your Income cover all living expenses including medical",
                    "Do you have an emergency fund",
                    "High Annuity to net worth ratio",
                    "High Fixed Rate",
                    "Income Rider Loss",
                    "Income Rider VS Income Rider",
                    "Insufficient Replacement Reason",
                    "Internal Replacement Guidelines",
                    "I refuse",
                    "Is Not Based",
                    "Is your Income sufficient to cover future changes",
                    "Limited",
                    "Low Disposable Income",
                    "Low Liquid Assets",
                    "MN Recommendation Unsupported",
                    "MN Replacement not out of surrender term",
                    "MO Lookback",
                    "Nationwide under 36 months",
                    "Non-Resident",
                    "Non-US Funds",
                    "NY-Producer doesn't feel fixed annuity is in the customer's best interest",
                    "NY-Producer Limitations on products offered",
                    "NY-Producer feels product isn't in the customer's best interest",
                    "NY-Understanding of non-guaranteed elements",
                    "NY Reg60",
                    "NY Surrender Charges",
                    "Product Availability",
                    "Replacement prior to anniversary date",
                    "Replacement under 12 months",
                    "Replacement under 24 months",
                    "Reverse Mortgage",
                    "Suitability Client Call Issues",
                    "Surrender Charges",
                    "Unemployment",
                    "Watch Producer"
                  },
                  value: local!transaction.suitability.decision_results[1].decline_reason,
                  saveInto: local!transaction.suitability.decision_results[1].decline_reason,
                  showWhen: contains(
                    {
                      "Suitability Decline",
                      "Non-Suitability Decline"
                    },
                    tostring(
                      local!transaction.suitability.decision_results[1].outcome
                    )
                  )
                )
              },
              
            )
          },
          alignVertical: "MIDDLE",
          marginAbove: "LESS",
          marginBelow: "EVEN_LESS"
        ),
        
      },
      height: "AUTO",
      style: "NONE",
      shape: "ROUNDED",
      padding: "STANDARD",
      marginBelow: "STANDARD",
      showBorder: false,
      showShadow: true,
      
    ),
    rule!NW_verticalSpacer(n: 1),
    rule!NW_verticalSpacer(n: 1),
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: 'translation!{765a2893-6d2c-4330-8d7a-ac85f4a6f417}CMGT_BaseTranslations.{0c9868e3-27cc-42e9-82cf-81687e0a1e6e}Complete',
          saveInto: {
            a!save(
              local!transaction.meta_data,
              a!update(
                local!transaction.meta_data,
                "hitl_outcome",
                ri!quickActionType
              )
            ),
            a!save(ri!jsonResponse, a!toJson(local!transaction)),
            a!save(
              ri!buttonValue,
              cons!NW_TEXT_BUTTON_LABEL_SUBMIT
            )
          },
          style: "SOLID",
          submit: true,
          validate: true,
          color: cons!NW_COLOR_BUTTONS,
          
        )
      },
      secondaryButtons: {
        a!buttonWidget(
          label: 'translation!{765a2893-6d2c-4330-8d7a-ac85f4a6f417}CMGT_BaseTranslations.{651cf177-f30b-485b-900f-8aaf47805737}Cancel',
          style: "OUTLINE",
          submit: true,
          validate: false,
          value: true,
          saveInto: {
            a!save(
              ri!buttonValue,
              cons!NW_TEXT_BUTTON_LABEL_CANCEL
            )
          }
        )
      },
      
    )
  }
)

I am getting above error,when response from integration does not decsion_results in structure and user wants to update it, I am trying to find a solution so that in both the cases when value is there it should display and user can update it based on dropdown as well as if it is not there it should get updated in response.please help me regarding this scenario

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi  ,
    Since decision_results is not an array, Appian throws the error when you try to access index [1].
    Remove the [1] index wherever you are using it.
    So instead of:

    value: local!transaction.suitability.decision_results[1].decline_reason,
    saveInto: local!transaction.suitability.decision_results[1].decline_reason,
    showWhen: contains(
      {"Suitability Decline","Non-Suitability Decline"},
      tostring(local!transaction.suitability.decision_results[1].outcome)
    )


    correct one: 
    value: local!transaction.suitability.decision_results.decline_reason,
    saveInto: local!transaction.suitability.decision_results.decline_reason,
    showWhen: contains(
      {"Suitability Decline","Non-Suitability Decline"},
      tostring(local!transaction.suitability.decision_results.outcome)
    )


    Final Fix: Remove [1] from all references to decision_results.

Reply
  • 0
    Certified Senior Developer

    Hi  ,
    Since decision_results is not an array, Appian throws the error when you try to access index [1].
    Remove the [1] index wherever you are using it.
    So instead of:

    value: local!transaction.suitability.decision_results[1].decline_reason,
    saveInto: local!transaction.suitability.decision_results[1].decline_reason,
    showWhen: contains(
      {"Suitability Decline","Non-Suitability Decline"},
      tostring(local!transaction.suitability.decision_results[1].outcome)
    )


    correct one: 
    value: local!transaction.suitability.decision_results.decline_reason,
    saveInto: local!transaction.suitability.decision_results.decline_reason,
    showWhen: contains(
      {"Suitability Decline","Non-Suitability Decline"},
      tostring(local!transaction.suitability.decision_results.outcome)
    )


    Final Fix: Remove [1] from all references to decision_results.

Children
  • 0
    Certified Associate Developer
    in reply to Harshmodi

    Hi  ,I tried this one but I am getting this error,
    Interface Definition: Expression evaluation error [evaluation ID = b957b:b6ce2] : An error occurred while executing a save: java.lang.IllegalArgumentException: Invalid index: Cannot index property 'outcome' into type List of Dictionary

  • 0
    Certified Senior Developer
    in reply to mohiniv1048

    if possible can you please share any example or screenshot of how data is looking in that local variable which has been fetched from rule.

  • 0
    Certified Associate Developer
    in reply to Harshmodi

    Response structure is like this in local variable transaction
    transaction
       1
           suitability
                      decision_results
                                           1
                                                outcome
                                                decline_reason
                                                ........................
                                                other fields 
    There can be two scenario
    1. where decision_results and value of outcome and decline_reason is present,user will just update
    2. where decsion_results is not there in response,and that need to be added to the response structure,along with value selected by user

  • 0
    Certified Senior Developer
    in reply to mohiniv1048

    if this is the structure

    then please refer this updated code and try 

    a!localVariables(
      local!transaction: 
        {
          {
            suitability: {
              decision_results: {
                {
                  outcome: "Suitability Decline",
                  decline_reason: null,
    
                },
    
              }
            }
          },
    
        },
       
      {
        a!cardLayout(
          contents: {
            a!richTextDisplayField(
              value: {
                a!richTextItem(
                  text: "LABEL",
                  /*color: cons!NW_COLOR_WHITE,*/
                  size: "MEDIUM_PLUS",
                  style: "STRONG"
                )
              }
            )
          },
          height: "EXTRA_SHORT",
          /*style: cons!NW_COLOR_PRIMARY,*/
          marginBelow: "STANDARD"
        ),
        a!cardLayout(
          contents: {
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Suitability Status",
                      labelPosition: "ADJACENT",
                      required: true(),
                      placeholder: "------Select Suitability Status from the below List----",
                      choiceLabels: {
                        "Approved",
                        "NC Non-Suitability Not Taken-HO Decision",
                        "NC Suitability Not taken-HO Decision",
                        "Non-Suitability Decline",
                        "Not Taken",
                        "Partial Approve",
                        "Pending",
                        "Suitability Decline"
                      },
                      choiceValues: {
                        "Approved",
                        "NC Non-Suitability Not Taken-HO Decision",
                        "NC Suitability Not taken-HO Decision",
                        "Non-Suitability Decline",
                        "Not Taken",
                        "Partial Approve",
                        "Pending",
                        "Suitability Decline"
                      },
                      value: local!transaction[1].suitability.decision_results[1].outcome,
                      saveInto: local!transaction[1].suitability.decision_results[1].outcome,
    
                    )
                  }
                ),
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Decline Reasons",
                      required: true(),
                      labelPosition: "ADJACENT",
                      placeholder: "------Select Decline Reason from the below List----",
                      choiceLabels: {
                        "Advantages",
                        "CA Medi-Cal",
                        "CA Surrender Charges",
                        "Death Benefit Loss",
                        "Disability",
                        "Disadvantages",
                        "Does your Income cover all living expenses including medical",
                        "Do you have an emergency fund",
                        "High Annuity to net worth ratio",
                        "High Fixed Rate",
                        "Income Rider Loss",
                        "Income Rider VS Income Rider",
                        "Insufficient Replacement Reason",
                        "Internal Replacement Guidelines",
                        "I refuse",
                        "Is Not Based",
                        "Is your Income sufficient to cover future changes",
                        "Limited",
                        "Low Disposable Income",
                        "Low Liquid Assets",
                        "MN Recommendation Unsupported",
                        "MN Replacement not out of surrender term",
                        "MO Lookback",
                        "Nationwide under 36 months",
                        "Non-Resident",
                        "Non-US Funds",
                        "NY-Producer doesn't feel fixed annuity is in the customer's best interest",
                        "NY-Producer Limitations on products offered",
                        "NY-Producer feels product isn't in the customer's best interest",
                        "NY-Understanding of non-guaranteed elements",
                        "NY Reg60",
                        "NY Surrender Charges",
                        "Product Availability",
                        "Replacement prior to anniversary date",
                        "Replacement under 12 months",
                        "Replacement under 24 months",
                        "Reverse Mortgage",
                        "Suitability Client Call Issues",
                        "Surrender Charges",
                        "Unemployment",
                        "Watch Producer"
                      },
                      choiceValues: {
                        "Advantages",
                        "CA Medi-Cal",
                        "CA Surrender Charges",
                        "Death Benefit Loss",
                        "Disability",
                        "Disadvantages",
                        "Does your Income cover all living expenses including medical",
                        "Do you have an emergency fund",
                        "High Annuity to net worth ratio",
                        "High Fixed Rate",
                        "Income Rider Loss",
                        "Income Rider VS Income Rider",
                        "Insufficient Replacement Reason",
                        "Internal Replacement Guidelines",
                        "I refuse",
                        "Is Not Based",
                        "Is your Income sufficient to cover future changes",
                        "Limited",
                        "Low Disposable Income",
                        "Low Liquid Assets",
                        "MN Recommendation Unsupported",
                        "MN Replacement not out of surrender term",
                        "MO Lookback",
                        "Nationwide under 36 months",
                        "Non-Resident",
                        "Non-US Funds",
                        "NY-Producer doesn't feel fixed annuity is in the customer's best interest",
                        "NY-Producer Limitations on products offered",
                        "NY-Producer feels product isn't in the customer's best interest",
                        "NY-Understanding of non-guaranteed elements",
                        "NY Reg60",
                        "NY Surrender Charges",
                        "Product Availability",
                        "Replacement prior to anniversary date",
                        "Replacement under 12 months",
                        "Replacement under 24 months",
                        "Reverse Mortgage",
                        "Suitability Client Call Issues",
                        "Surrender Charges",
                        "Unemployment",
                        "Watch Producer"
                      },
                      value: local!transaction[1].suitability.decision_results[1].decline_reason,
                      saveInto: local!transaction[1].suitability.decision_results[1].decline_reason,
                      showWhen: contains(
                        {
                          "Suitability Decline",
                          "Non-Suitability Decline"
                        },
                        tostring(
                          local!transaction[1].suitability.decision_results[1].outcome
                        )
                      )
                    )
                  },
    
                )
              },
              alignVertical: "MIDDLE",
              marginAbove: "LESS",
              marginBelow: "EVEN_LESS"
            ),
    
          },
          height: "AUTO",
          style: "NONE",
          shape: "ROUNDED",
          padding: "STANDARD",
          marginBelow: "STANDARD",
          showBorder: false,
          showShadow: true,
    
        ),
        
    
      }
    )