Interface Definition: Expression evaluation error at function a!forEach [line 42]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!multipleDropdownField [line 216]: A multiple dropdown component

Hi,

I used multidrop down field in the interface, now I want to show in site with the readonly format, when I am calling this interface by keeping readonly=true I am facing this error can anyone help me out with this error.

below is my code of the interface

a!localVariables(
  
  local!item:'type!{urn:com:appian:types:SHA}SHA_newList'(),
  local!propertyTypeList:rule!SHA_quertyTogetThePropertyTypeName(),
  local!ammenityTypeList:rule!SHA_quertyTogetTheAmmenityType(),
  local!mappingKey: {1},
  local!Doc:'type!{urn:com:appian:types:SHA}SHA_document'(),

  {
    a!sectionLayout(
      label:"",
      contents:{
        a!richTextDisplayField(
          label:"",
          value: a!richTextItem(
            text:"Add Listing ",
            size:"LARGE",
            style:"STRONG"
          )
        )
      },
      divider:"BELOW"
    ),
    a!sectionLayout(
      label:"",
      contents: {
        a!richTextDisplayField(
          labelPosition:"COLLAPSED",
          value: {
            a!richTextItem(
              text: {
                a!richTextIcon(icon:"industry"),
                "Listing"
              },
              color:"STANDARD",
              size:"MEDIUM_PLUS",
              style:"STRONG"
            )
          })},
          divider:"BELOW"
    ),
    a!forEach(
      items:if(
        ri!isReadOnly,
        ri!listing,
        local!item
      ),
      expression:
        a!localVariables(
          local!ammenities,
          local!document,
          local!mappingId:index(local!mappingKey,fv!index,null),
          a!boxLayout(
            label:"Listing" & fv!index,
            contents: {
              a!sideBySideLayout(
                items: {
                  a!sideBySideItem(
                    item: 
                    a!dropdownField(
                      label:"Property Type", 
                      placeholder:"select a type",
                      choiceLabels:index(local!propertyTypeList,"propertyTypeNm",null),
                      choiceValues:index(local!propertyTypeList,"propertyTypeId",null),
                      value:fv!item.propertyTypeIdFk,
                      saveInto:{
                        a!save(fv!item.mappingKey,local!mappingId),
                        fv!item.propertyTypeIdFk

                      },
                      required:true,
                      disabled: ri!isReadOnly=true()
                    )
                  ),
                  a!sideBySideItem(
                    item: 
                    a!textField(
                      label:"Property Name",
                      placeholder:"enter the Name",
                      value:fv!item.propertyName,
                      saveInto:fv!item.propertyName,
                      readOnly:ri!isReadOnly 
                    )

                  )}), 
                  a!sideBySideLayout(
                    items: {
                      a!sideBySideItem(
                        item:
                        a!textField(
                          label:"Property Description",
                          placeholder: "enter the description",
                          value:fv!item.propertyDescription,
                          saveInto:fv!item.propertyDescription,
                          readOnly:ri!isReadOnly
                        )

                      ),
                      a!sideBySideItem(
                        item:
                        a!textField(
                          label:"Property Address",
                          value:fv!item.propertyAddress,
                          saveInto:fv!item.propertyAddress,
                          readOnly:ri!isReadOnly
                        )

                      )

                    }),
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item:
                          a!textField(
                            label:"Floor PlaneName",
                            value:fv!item.floorPlanName,
                            saveInto:fv!item.floorPlanName,
                            readOnly:ri!isReadOnly
                          )

                        ),
                        a!sideBySideItem(
                          item:a!textField(
                            label:"Neighborhood",
                            value:fv!item.neighborhood,
                            saveInto:fv!item.neighborhood,
                            readOnly:ri!isReadOnly
                          )
                        )

                      }
                    ),
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item:a!textField(
                            label:"Price",
                            value:fv!item.price,
                            saveInto:fv!item.price,
                            readOnly:ri!isReadOnly
                          )

                        ),
                        a!sideBySideItem(
                          item:a!textField(
                            label:"Square FootAge",
                            value:fv!item.squareFootage,
                            saveInto:fv!item.squareFootage,
                            readOnly:ri!isReadOnly
                          ) 
                        )

                      }
                    ),
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item: a!dropdownField(
                            label:"Bed Rooms",
                            placeholder:"select a value",
                            choiceLabels:cons!SHA_BEDROOMLIST,
                            choiceValues:cons!SHA_BEDROOMLIST,
                            value:fv!item.bedRooms,
                            saveInto:fv!item.bedRooms,
                            disabled:ri!isReadOnly


                          )
                        ),
                        a!sideBySideItem(
                          item:a!dropdownField(
                            label:"Bath Rooms",
                            placeholder:"select a value",
                            choiceLabels:cons!SHA_BEDROOMLIST,
                            choiceValues:cons!SHA_BEDROOMLIST,
                            value:fv!item.bathRooms,
                            saveInto:fv!item.bathRooms,
                            disabled:ri!isReadOnly

                          )
                        )

                      }
                    ),
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item:a!dropdownField(
                            label:"Pets",
                            placeholder:"select a value",
                            choiceLabels:{"Cat","Dogs","Kangoors","Rabbits","Tortoise","none"},
                            choiceValues:{"Cat","Dogs","Kangoors","Rabbits","Tortoise","none"},
                            value:fv!item.pets,
                            saveInto:fv!item.pets,
                            disabled:ri!isReadOnly

                          )
                        ),
                        a!sideBySideItem(
                          item:
                          a!radioButtonField(
                            label:"Double Occupancy",
                            choiceLabels:{"Yes","No"},
                            choiceValues:{"Yes","No"},
                            value:fv!item.doubleOccupancy,
                            saveInto:fv!item.doubleOccupancy,
                            disabled:ri!isReadOnly


                          )
                        )


                      }),
                      a!multipleDropdownField( 
                        label:"Ammenities",
                        placeholder:"chooose",
                        choiceLabels:
                        if(
                        ri!isReadOnly,
                        a!forEach(
                          items:  index(ri!ammenities,property(ri!ammenities.ammenityTypeIdFk,ri!ammenities.listingIdFk,null)),
                          expression: ri!ammenities
                            
                          ),
                           
                        
                        index(local!ammenityTypeList,"ammenityTypeNm",null)
                        ),
                       
                        choiceValues:
                       if(
                         ri!isReadOnly,
                         a!forEach(
                          items:ri!ammenities,
                          expression:
                          wherecontains(ri!ammenities.listingIdFk,ri!ammenities.ammenityTypeIdFk)
                         ),
                       
                        index(local!ammenityTypeList,"ammenityTypeId",null)
                      ),
                       
                        value:ri!ammenities,
                        saveInto:
                        {
                         
                          a!save(
                          ri!ammenities,/*empty set*/
                            a!forEach(
                              index(reverse({save!value}),1),/*component updated values*/ 
                              'type!{urn:com:appian:types:SHA}SHA_newAmmenities'(
                                ammenityTypeIdFk:fv!item,
                                mappingKey: local!mappingId
                             ))),
                             
                        
                        local!ammenities} ,
                        disabled:ri!isReadOnly
                      ),


                      a!sectionLayout(
                        label:"",
                        contents: {
                          a!richTextDisplayField(
                            labelPosition:"COLLAPSED",
                            value:{
                              a!richTextIcon(
                                icon:"file-text",
                                color:"ACCENT",
                                size:"LARGE" 
                              ),
                              a!richTextItem(
                                text:"Document",
                                color:"SECONDARY",
                                size:"LARGE",
                                style:"STRONG"
                              )
                            }
                          )
                        },
                        divider:"BELOW"
                      ),
                      a!gridLayout(
                        label:"",
                        headerCells:{
                          a!gridLayoutHeaderCell(label:"Upload"),
                          a!gridLayoutHeaderCell(label:"DocDescription"),
                          a!gridLayoutHeaderCell(label:" ")
                        },
                        columnConfigs:{},
                        rows:{
                          a!forEach(
                            items:{
                              if(
                                ri!isReadOnly,
                                ri!Document,
                              if(
                              rule!FCO_isNullOrBlank(ri!Document),
                              null,
                              ri!Document[wherecontains(local!mappingId,ri!Document.mappingKey)]
                            )
                            )},

                            expression:a!gridRowLayout(
                              contents:{
                                a!fileUploadField(
                                  label:"Upload Document",
                                  target:cons!SHA_FOLDER,
                                  maxSelections:1, 
                                  value:fv!item.appianDocId,
                                  saveInto:{
                                    fv!item.appianDocId

                                  },
                                  required: true(),
                                  requiredMessage:"Please upload document",
                                  disabled:ri!isReadOnly
                                ),
                                a!textField(
                                  label:"docdescription",
                                  placeholder:"enter doc description",
                                  value:fv!item.docDescription,
                                  saveInto:fv!item.docDescription,
                                  required: true(),
                                  readOnly:ri!isReadOnly

                                ),
                                a!richTextDisplayField(
                                  labelPosition: "",
                                  value: {
                                    a!richTextIcon(
                                      icon:"trash-o",
                                      link: a!dynamicLink(
                                        value:fv!index,
                                        saveInto:a!save(ri!Document,remove(ri!Document,fv!index))

                                      ),
                                      color:"NEGATIVE",
                                      size:"STANDARD"
                                    )
                                  }

                                )

                              }
                            )
                          )
                        },
                        selectionValue:ri!Document,
                        selectionSaveInto:ri!Document,
                        selectable: {},
                        selectionRequired:false,
                        selectionDisabled:{},
                        addRowLink:a!dynamicLink(
                          label: "Upload New File",
                          value:true(),
                          saveInto:{
                            /*a!save(*/
                            /*ri!Document,append(ri!Document,local!document) */
                            /*),*/
                            a!save(
                              ri!Document,
                              append(
                                ri!Document,/*empty set*/
                                a!forEach(
                                  index(reverse({save!value}),1),/*component updated values*/
                                  'type!{urn:com:appian:types:SHA}SHA_document'(
                                    mappingKey: local!mappingId
                                  )))),
                                  local!Document

                          }
                        ),
                        validations: {},
                        shadeAlternateRows:true
                      )
            })
        )),


        a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              label: "ADD ANOTHER LIST",
              icon: "plus-circle",
              value:if(ri!isReadOnly,ri!listing,local!item),
              saveInto:{
                a!save(
                  local!item,
                  append(local!item,'type!{urn:com:appian:types:SHA}SHA_newList'())
                ),
                a!save(
                  local!Doc,
                  append(local!Doc,'type!{urn:com:appian:types:SHA}SHA_document'())
                ),
                a!save(
                  local!mappingKey,
                  append(
                    local!mappingKey,
                    index(local!mappingKey,length(local!mappingKey),null)+1
                  )
                )
              },
              size:"SMALL",
              style:"NORMAL",
              showWhen: ri!isReadOnly=false(),
            )

          },
          align: "CENTER",
          marginBelow: "STANDARD"
        ),

        a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              value:"Submit",
              saveInto:{
                ri!buttons,
                a!save(
                  ri!listing,
                  local!item
                )

              },
              submit: true,
              style: "PRIMARY",
              showWhen: ri!isReadOnly=false(),

            )
          },
          secondaryButtons: {
            a!buttonWidget(
              label: "Cancel",
              value:"Cancel",
              saveInto:ri!buttons,
              submit: true,
              style: "DESTRUCTIVE",
              showWhen: ri!isReadOnly=false(),
              validate: false

            )
          }
        )
  }

)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    The a!forEach statement inside your choiceValues isn't returning members of the ri!ammenities CDT.  Instead it'll be returning the result of the whereContains() call, which results in an array of integers.  Also your choiceLabels array would need to match and it looks to me like you're using entirely different logic in the a!forEach() you're using in its ReadOnly declaration.

    Honestly I'd suggest one of two fundamental alterations to your approach here:  either 1) just show your normal set of choices and values even when "isReadOnly" is true, getting rid of those a!forEach wrappers, or 2) show a different type of field (like paragraph or rich text) when displaying the Read Only data - for example with Rich Text you could show a bulleted list or whatever seems most appropriate to you.

Reply
  • 0
    Certified Lead Developer

    The a!forEach statement inside your choiceValues isn't returning members of the ri!ammenities CDT.  Instead it'll be returning the result of the whereContains() call, which results in an array of integers.  Also your choiceLabels array would need to match and it looks to me like you're using entirely different logic in the a!forEach() you're using in its ReadOnly declaration.

    Honestly I'd suggest one of two fundamental alterations to your approach here:  either 1) just show your normal set of choices and values even when "isReadOnly" is true, getting rid of those a!forEach wrappers, or 2) show a different type of field (like paragraph or rich text) when displaying the Read Only data - for example with Rich Text you could show a bulleted list or whatever seems most appropriate to you.

Children