I'm using Agilepoint to build a form. in this form I have a multiselect control, from which I need to let the user choose several items, to later insert them into a list. what I'm trying to do is that after the user chooses the item she needs, I run a script that loops through the array in the control, and each selected item is saved in a different field, then I use OOTB tools to insert it to the list.
I managed to write a script that loops and identifies the selected items, but for some reason it saves only the last item value to the different field mentioned before.
using the developers tools, it seems like the script is running correctly. seeing that the last value has been saved to the different field, I see no problem in saving the value there. Moreover - the script does activate something out of the field - after the console log in the middle is a script to add a row to the list mentioned before - and it create the right number of rows.
Any help would be appreciated.
this is the code
function CheckItem(){
var Item = document.getElementById("ResponsibleInchargeFinalMultiple");
var Len = Item.length;
var TempField = document.getElementById("TempUserForMail").value;
var i = 0
for (var i = 0; i < Len; i++){
if (Item[i].selected){
var ItemValue = Item[i].value;
document.getElementById("TempUserForMail").value = ItemValue;
console.log(ItemValue);
alert(ItemValue);
var options = {};
options. fieldId = 'UserstoRead';
options.value = [{}];
eFormHelper.addRowsToSubForm(options, function (result)
{
if (result.isSuccess)
{
console.log(result.data); //logs the data holds the empty object
}
else
{
console.log(result.error); // logs the hold exception object
}
});
};
};
}
thanks!