Editable grid dropdowns

Hello, I have editable grid in which I have 3 dropdowns, I'm picking up the values and choices from constants and have rule decisions based on that now for the first row it's working perfectly fine I select "Region" then "Country" and then "Language", but once I add new row I loose all the values from second and 3rd dropdowns and they become blank and I'm not able to select anything.

Here is the full code for the a!foreach is it something within the add row function?


                    rows: a!forEach(
                        items: ri!AOS_Documents_Required,
                        expression: a!gridRowLayout(
                          id: fv!index,
                          contents: {
                            a!dropdownField(
                              choiceLabels: cons!AOS_Regions,
                              choiceValues: cons!AOS_Regions,
                              label: "Dropdown",
                              labelPosition: "ABOVE",
                              placeholder: "--- Select a Value ---",
                              value: fv!item['recordType!AOS_Documents_Required.fields.Region'],
                              saveInto: fv!item['recordType!AOS_Documents_Required.fields.Region'],
                              searchDisplay: "AUTO",
                              validations: {}
                            ),
                            a!dropdownField(
                              choiceLabels: rule!AOS_region_country(region: ri!AOS_Documents_Required['recordType!AOS_Documents_Required.fields.Region']),
                              choiceValues: rule!AOS_region_country(region: ri!AOS_Documents_Required['recordType!AOS_Documents_Required.fields.Region']),
                              label: "Dropdown",
                              labelPosition: "ABOVE",
                              placeholder: "--- Select a Value ---",
                              value: fv!item['recordType!AOS_Documents_Required.fields.Country_Template'],
                              saveInto: fv!item['recordType!AOS_Documents_Required.fields.Country_Template'],
                              searchDisplay: "AUTO",
                              validations: {}
                            ),
                            a!dropdownField(
                              choiceLabels: rule!AOS_country_language(country: ri!AOS_Documents_Required['recordType!AOS_Documents_Required.fields.Country_Template']),
                              choiceValues: rule!AOS_country_language(country: ri!AOS_Documents_Required['recordType!AOS_Documents_Required.fields.Country_Template']),
                              label: "Dropdown",
                              labelPosition: "ABOVE",
                              placeholder: "--- Select a Value ---",
                              value: fv!item['recordType!AOS_Documents_Required.fields.SDS_Language'],
                              saveInto: fv!item['recordType!AOS_Documents_Required.fields.SDS_Language'],
                              searchDisplay: "AUTO",
                              validations: {}
                            ),
                            a!richTextDisplayField(
                              value: a!richTextIcon(
                                icon: "close",
                                link: a!dynamicLink(
                                saveInto : a!save(
                                  ri!AOS_Documents_Required,
                                  remove(ri!AOS_Documents_Required, fv!index)
                                )
                                ),
                                linkStyle: "STANDALONE",
                                color: "NEGATIVE"
                              )
                            )
                          }
                        )
                      ),
                      selectionSaveInto: {},
                      addRowLink: a!dynamicLink(
                        label: "Add new",
                        saveInto: ri!AOS_Documents_Required,
                        value: append(
                          ri!AOS_Documents_Required,
                          'recordType!AOS_Documents_Required'()
                        )
                      ),
                      validations: {},
                      shadeAlternateRows: true

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hello ,

    Try differentiating the rows by an id while you click add row link.

    And save the value in proper way.

    value: 'recordType!AOS_Documents_Required'(

    documentId: count(ri!AOS_Documents_Required) +1

    ),

    saveInto: a!save(

    ri!AOS_Documents_Required,

    append(
                              ri!AOS_Documents_Required,
                              save!value
                            )

    )

    Refer the Editable Grid for reference.

  • After following what you suggested I got error in the expression:

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!dynamicLink [line 402]: Keys must be record field references or record relationship references

                        addRowLink: a!dynamicLink(
                            label: "Add new",
                            value: 'recordType!{c80b9de7-a15f-41db-8c92-5cb6b7aa7ce3}AOS_Documents_Required'(
                              DocumentID: count(ri!AOS_Documents_Required) +1
                            ),
                            saveInto: a!save(
                              ri!AOS_Documents_Required,
                              append(
                                ri!AOS_Documents_Required,
                                save!value
                              )
                            )
                          ),
                          validations: {},
                          shadeAlternateRows: true

  • 0
    Certified Lead Developer
    in reply to Shwapx

    You need to change this snippet

    value: 'recordType!AOS_Documents_Required'(
    
    documentId: count(ri!AOS_Documents_Required) +1
    
    ),

    according to the way how record fields are referenced.

    https://docs.appian.com/suite/help/24.1/reference-records.html

    something like this:

    value: 'recordType!AOS_Documents_Required'(
    
    'recordType!AOS_Documents_Required'.fields.'documentId': count(ri!AOS_Documents_Required) +1
    
    ),

  • That fix the error, but not fix the solution.   




    The weird is when I add more fields the first 2 are starting with document id 2 then it's going 3, 4.. etc..

    adding first row is no problem:



    then after I click on add new i got an error:

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 347]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!dropdownField [line 363]: A dropdown component [label="Dropdown"] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was USA and choiceValues was .

    Seems like it's picking the values from above or idk what exactly is happening.

    I feel like if I work with local variables everything is working good, but then I'm not able to pass this into process model to save the data in records.


  • 0
    Certified Lead Developer
    in reply to Shwapx

    The documentation of the count() function says:

    "Returns the number items in all arrays passed to the function. Null parameters are also counted."

    That's exactly explains the behaviour you observe. An empty list counts to 1, adding 1 equals 2. After adding the first item, count() returns 1 again.

    Regarding drop downs, I highly suggest to do your research and learning outside a grid. Once you fully understand how these work, continue with that grid. 

  • Do not make much sense why returns 1, how to work around this. Even if I fill out the first row properly and click on new row I got error that the values are invalid:

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 347]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!dropdownField [line 363]: A dropdown component [label="Dropdown"] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was USA and choiceValues was .

  • 0
    Certified Lead Developer
    in reply to Shwapx

    The two issued have nothing to do with each other.

    To the dropdown problem. The error message is very clear. The value you pass into, does not exist in the list of available values.

  • But this issue with the value appear once I have field the first row and click on add new row.

    I fill the first one and when I click on add new row this is the message I got.

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 347]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!dropdownField [line 366]: A dropdown component [label="Dropdown"] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was USA and choiceValues was .

    It supposed to add empty row I'm not passing any values. And all the choice values are coming from constants. ...

  • 0
    Certified Lead Developer
    in reply to Shwapx

    Looking at your code, I see that lines 19 and 30 refer to non-constant values.

    Again, to chase down a complex issue, I highly recommend to try to isolate it. Make things working in a simplified example first.

  • Yes line 19 and 30 there I have the rule (which is decision tree) based on selected region to show me certain countries and after that based on country to show me certain languages which works for first row, but adding next give that error. 

Reply Children