Page Variable Erased

I have a page variable that looks like this.

{
  player_id: "6121e7a4c5a05b6bced77658",
  measurement_id: "6121e71ec5a05b6bced7764b",
  date: "2021-10-06",
  units: "mph",
  values: [ {value: 75}, {value: 76}, {value: 73}, ...]         
}

I set the values of this page variable with a date picker for date:, a couple dropdowns for player and measurement. The units come from the measurement so when a user selects a measurement from the dropdown (like 60 yd dash), a Set Page Variable looks up the units with the measurement_id from a Data Variable in the app and writes the results to the page variable units (seconds) which is shown on the page. The formula for setting the units is (this works off of Property ‘Selected Value’ changed event on the measurement dropdown.

FIND(data.measurements, item._id.$oid == self.value).UOM

The problem is that when I push the icon button to add a value to values, the units page variable is erased. None of the other properties of the page variable are changed - just units. My Set Page Variable formula looks like this.

INSERT_ITEM_AT(pageVars.Entry.values, COUNT(pageVars.Entry.values), {"value": null}) 

I’ve tried it in both the Legend and Preview app on my iPhone 11 (iOS 14.7.1). Both do the same thing. In my browser (latest Firefox) the app works fine and units is not erased.

Any ideas?

Hi!

Hmm. Are you still experiencing problems with this or did you get it solved? My guess is that you need to use SET_KEY where you are setting the page variable, as it looks like you would then set only an empty page variable with only the array of values. So the formula would be something like SET_KEY(pageVars.Entry, "values", INSERT_ITEM_AT(...))