Values are not properly assigning in variables

I think, I might have addressed this one in my previous queries. 

I have a dropdown with name "Request Type" having two choices "Supply" and "Service", and there is one "Item" textfield in which Item Name needs to be entered. When user selects a "Service", then "Item" value should be stored in "Service Type" table and for "Supply" in "Supply Type" table, which is occurring with the code I have written, but the issue is "If user suppose in between changes the "Request Type" from "Service" to "Supply", then "Item" value stored in "Service Type" CDT should return back to null state and newly entered "Item" value should store in "Supply Type" CDT, which is not coming up and it's retaining both Item values in both CDTs, i.e Ex- He entered "PC" for "Supply" but then changed it's "Request Type" to "Service" and entered Item as "S/w Installation", then as a result "Supply Type" CDT has Item value "PC", and with that "Service Type" CDT has Item value "S/w Installation", which shouldn't be the case i.e. Item value "PC" in "Supply Type" CDT should default back to null.

Code below:

a!forEach(
          items: ri!requestTypeRef,
          expression: a!gridRowLayout(
            id: fv!index,
            contents: {
              a!dropdownField(
                label: "request type " & fv!index,
                placeholderLabel: "---Please select value---",
                choiceLabels: cons!OSR_TEXT_ARRAY_REQUEST_TYPE,
                choiceValues: cons!OSR_TEXT_ARRAY_REQUEST_TYPE,
                value: index(fv!item, "RequestTypeName", {}),
                saveInto: fv!item.RequestTypeName,
                required: true
              ),
              a!textField(
                label: "item " & fv!index,
                value: if(
                  ri!requestTypeRef[fv!index].RequestTypeName = "Service",
                  index(
                    ri!serviceTypeRef[fv!index],
                    "ServiceTypeName",
                    {}
                  ),
                  index(
                    ri!supplyTypeRef[fv!index],
                    "SupplyTypeName",
                    {}
                  )
                ),
                saveInto: if(
                  ri!requestTypeRef[fv!index].RequestTypeName = "Service",
                  ri!serviceTypeRef[fv!index].ServiceTypeName,
                  ri!supplyTypeRef[fv!index].SupplyTypeName
                ),
                required: true
              )

Thanks

Parents Reply Children
No Data

 Discussion posts and replies are publicly visible