Skip to main content
pd0001
February 23, 2022
Question

Interface Definition: Expression evaluation error at function a!textField [line 56]: Invalid index: Cannot index property 'shippingAddress' of type Text into type

  • February 23, 2022
  • 9 replies
  • 0 views

I am getting below error::

 

Interface Definition: Expression evaluation error at function a!textField [line 56]: Invalid index: Cannot index property 'shippingAddress' of type Text into type

Boolean

 

 

My code is:

 

a!localVariables(

  local!locationsList: rule!AIP_getAddress(addressId: NULL),

  local!addingAddress : false(),

  local!newAddress : 'type!{urn:com:appian:types:AIP}AIP_address'(),

  {

    a!sectionLayout(

      label: "Address",

      contents: {

        a!radioButtonField(

          label: "Radio Buttons",

          labelPosition: "COLLAPSED",

          choiceLabels:

          a!forEach(

            items: local!locationsList,

            expression: fv!item.shippingAddress & " " &

            if(isnull(fv!item.unitNumber), null, "Unit #" & fv!item.unitNumber)

            & " " & fv!item.city & ", " & fv!item.stateOrProvince & " "

            & fv!item.postalCode

          ),

          choiceValues: local!locationsList,

          value: ri!address,

          saveInto: ri!address,

          choiceLayout: "STACKED",

          validations: {}

        )

      }

    ),

    a!richTextDisplayField(

      labelPosition: "COLLAPSED",

      value: {

        a!richTextIcon(

          icon: "plus"

        ),

        " ",

        a!richTextItem(

          text: {

            "Add New Address"

          },

          link: a!dynamicLink(

            label: "Dynamic Link",

            value: true(),

            saveInto: local!addingAddress

          ),

          style: {

            "STRONG"

          }

        )

      }

    ),

    a!boxLayout(

      label: "Add New Address",

      contents: {

        a!sideBySideLayout(

          items: {

            a!sideBySideItem(

              item: a!textField(

                label: "Shipping Address",

                labelPosition: "ABOVE",

                value: local!newAddress.shippingAddress,

                saveInto: local!newAddress.shippingAddress,

                refreshAfter: "UNFOCUS",

                required: true,

                validations: {}

              )

            ),

            a!sideBySideItem(

              item: a!textField(

                label: "Unit number",

                labelPosition: "ABOVE",

                value: local!newAddress.unitNumber,

                saveInto: local!newAddress. unitNumber,

                refreshAfter: "UNFOCUS",

                validations: {}

              )

            )

          }

        ),

        a!sideBySideLayout(

          items: {

            a!sideBySideItem(

              item: a!textField(

                label: "City",

                labelPosition: "ABOVE",

                value: local!newAddress.city,

                saveInto: local!newAddress.city,

                refreshAfter: "UNFOCUS",

                required: true,

                validations: {}

              ),

              width: "2X"

            ),

            a!sideBySideItem(

              item: a!textField(

                label: "State/Province",

                labelPosition: "ABOVE",

                value: local!newAddress,

                saveInto: local!newAddress,

                refreshAfter: "UNFOCUS",

                required: true,

                validations: {}

              ),

              width: "1X"

            ),

            a!sideBySideItem(

              item: a!textField(

                label: "Postal Code",

                labelPosition: "ABOVE",

                value: local!newAddress,

                saveInto: local!newAddress,

                refreshAfter: "UNFOCUS",

                required: true,

                validations: {}

              ),

              width: "1X"

            )

          }

        ),

        a!buttonArrayLayout(

          buttons: {

            a!buttonWidget(

              label: "ADD",

              saveInto: {

                a!save(local!locationsList,append(local!locationsList,local!newAddress)),

                a!save(ri!address,local!newAddress),

                a!save(local!newAddress,{addreessId: null,shippingAddress:" ",unitNumber:null,city:" ",

  stateOrProvince: " ",postalCode : null}),

                a!save(local!addingAddress,false())

              },

              style: "PRIMARY",

              validate: true

            )

          },

          align: "END"

        )

      },

      showWhen: local!addingAddress,

      style: "ACCENT",

      marginBelow: "STANDARD"

    )

  }

  )

 

 

I have attached the screenshot for reference . Kindly guide me please.

    9 replies

    gopalk2865
    Participating Frequently
    February 23, 2022

    Hi , From the code , it looks like you are not using correct indexes in your text fields.  Try to fix the index, something like below

     a!sideBySideItem(
    
                  item: a!textField(
    
                    label: "Postal Code",
    
                    labelPosition: "ABOVE",
    
                    value: local!newAddress.postalCode,
    
                    saveInto:local!newAddress.postalCode,
    
                    refreshAfter: "UNFOCUS",
    
                    required: true,
    
                    validations: {}
    
                  )

    pd0001
    pd0001Author
    February 23, 2022

    I have tried the same way as you mentioned. You can check on my code as well.

    gopalk2865
    Participating Frequently
    February 23, 2022

    Hi pd0001 , I am not able to see your CDT structure . from the error looks like you are trying to index text field into boolean field. Did you check what  value local!newAddress is having . i think you need to refresh your interface

    harshitb6843
    February 23, 2022

    Hi there,

    Cast the value to a string before saving it in the variable. That should resolve the issue. 

    pd0001
    pd0001Author
    February 23, 2022

    If possible ,can u give a example with code?

    rickyc0006
    February 23, 2022

    Hi,

    try using index function like in index(local!newAddress,"shippingAddress",null) 

     https://docs.appian.com/suite/help/21.4/fnc_array_index.html

    February 24, 2022

    In CDT 'type!{urn:com:appian:types:AIP}AIP_address'(), you might have declared shipping Address as boolean,please check it