Skip to main content
Known Participant
May 5, 2023
Question

An error occurred while executing a save: java.lang.ClassCastException: com.appiancorp.core.expr.portable.Value cannot be cast to com.appiancorp.core.data.Variant

  • May 5, 2023
  • 7 replies
  • 10 views

Hi,

Sometimes on UI getting the below error:

Expression evaluation error [evaluation ID = 19742:9c777] in rule 'Test_Rule' at function a!dropdownField [line 314]: An error occurred while executing a save: java.lang.ClassCastException: com.appiancorp.core.expr.portable.Value cannot be cast to com.appiancorp.core.data.Variant

Please provide some guidance on the above error to fix.

Regards,
Sandeep

    7 replies

    Participating Frequently
    May 5, 2023

    The error points out that when you select a dropdown value (of the dropdown component at line 314), a save is executed in which the target type and value type do not line up.

    i.e. you are trying to save some value of type A into a target that expects type B value.

    This obviously will not work.

    Inspiring
    May 5, 2023

    Error message itself is a clear guidance. If you can share the code snippet we might help you solve this error faster.

    Known Participant
    May 5, 2023

    Thank you Laurens and Sanchit,

    Please review the attached code:

    a!localVariables(
      local!id,
      local!unionChoicelabels: union("A", "A", "B", "B"),
      local!unionChoiceValues: union(1, 1, 2, 2),
      local!number,
      local!Detail: 
      cast(
        typeof(
          'type!{urn:com:appian:types:AAA}AAA_Details'()
        ),
        {}
      ),
      a!dropdownField(
        label: "Select SMT",
        labelPosition: "JUSTIFIED",
        helpTooltip: "Select the name of the SMT",
        placeholder: "Select SMT",
        choiceLabels: local!unionChoicelabels,
        choiceValues: local!unionChoiceValues,
        value: local!id,
        saveInto: {
          local!id,
          a!save(local!number, null),
          a!save(local!Detail.id, local!id)
        },
        required: true,
        validations: {}
      )
    )

    Inspiring
    May 5, 2023

    This piece of code looks fine and working. You might mind sharing the actual code where the error occurs at line 314.