I have an array within my Session Storage named Response with two fields (Question and Answer).
There isn’t a way to add to the array fields in Session Storage, it only has a Set action.
The Array component does have additional actions like Add item, but there doesn’t appear to be a way to add fields to the array, so what’s the best way to populate the array in Session Storage?
I cannot figure out how to add dynamic values. I’ve tried the follow way, without success:
. [{"Question":"{{steppersurveyv2.companysizequestion1.value}}","Answer":"{{steppersurveyv2.radiogroup.companysize0110.value}}"}]
Having a custom formatter to push an element to an array: (I don’t know if such functionality is already present in Wappler, I haven’t learned anything about the new Array functions in Wappler)
exports.push = function (arr, item) {
arr.push(item);
return arr;
}
In Set Session Storage Item (your 2nd screenshot), in the Value expression, select the existing Response array, plus .push(new_item), this will return a new array with the new object contained in it (as well as the previous elements)
I have the same issue in my app, and I have two different data stores, one for the contacts and one for the questions/ answers… and they are linked by a contact_id field common to each.
I got it to work thanks to this bug report. You don’t need to go to Array first, you can populate the keyed array in the Local Storage directly after getting past the bug that doesn’t show the fields in the array.