Error with cascading drop down

I have two level cascading dropdown in an editable grid. In the grid there is a "Add new row" which adds a new row on every click. 

The issue is with the variable (local!items) I am using to generate the choice values of the second drop down (Item drop down). For the first row in the grid, it populates correct, but when user clicks to add second row and then try to select values in first dropdown, then it shows error.

I know the reason why the error as the variable is not updating on every new row addition. I'm unable to figure out the way and have hard time resolving this error.

Attached is the snippet of code I have and screenshot of error.

Any help is highly appreciated.

Thanks!

a!localVariables(

  local!supplyType: rule!OSR_QRY_T_Ref_getSupplyTypeDataByID(
    isActive: true()
  ), /* Gets all items in supply table to be used as Category */

  local!items,
  
  /* Code snippet starts here, these dropdowns are in foreach() of editable grid*/
             /* fv!item is a request row in editable grid */ 
              a!dropdownField(      /* first dropdown */
                label: "category " & fv!index,
                placeholderLabel: "---Please select Category---",
                choiceLabels: local!supplyType.data.SupplyTypeName,
                choiceValues: local!supplyType.data.SupplyTypeID,
                value: index(
                  fv!item,
                  "SupplyTypeID",
                  {}
                ),
                saveInto: {
                  fv!item.SupplyTypeID,
                  a!save(
                    local!items,             /* On every interaction with Category dropdown, this should be updated but it's not updating for items while generating a new row */ 
                    rule!OSR_QRY_T_Ref_getItemDataByID(
                      isActive: true(),
                      supplyTypeID: index(
                        fv!item,
                        "SupplyTypeID",
                        {}
                      )
                    ).data /* Gets Items in a specific supply category */
                  ),
                  a!save(
                    fv!item.ItemID,
                    null
                  )
                }
              ),
              
              a!dropdownField(         /* second dropdown */
                label: "item " & fv!index,
                placeholderLabel: "---Please select Item---",
                choiceLabels: index(
                  local!items,
                  "ItemName",
                  {}
                ),
                choiceValues: index(
                  local!items,
                  "ItemID",
                  {}
                ),
                value: index(
                  fv!item,
                  "ItemID",
                  {}
                ),
                saveInto: fv!item.ItemID
              )
)

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data