How to use form data object to insert data to table

My use case: I have a list view in my form with some checkboxes. I have a query that Inserts data into a table. I am running into an error when the form data object gets to the list view to insert see below.

image

My question is, how can I manipulate the form data object to grab each checkbox in the listview? Right now, it's trying to insert the whole list view I think. I understand why it fails because it's trying to insert the listview as a column but that doens't exist. I can't hard code it because in this app the user can add more questions to the listview. I know I'll have to add the columns to the table before the insert will work but I am trying to avoid having to edit the insert code as well when they want to make changes

I hope that made sense. If not, let me know so I can clarify further.

I was able to figure this out with some help from Stackoverflow:

let lstvw = GenAssyChkListFrm.data;

Object.assign(lstvw, ...lstvw.ga_questions.map((o, i) => ({['q' + (i + 1)]: o.ga_checkbox})),{"badge_num": txtBadgeNum.value},{"work_order": txtWONum.value},{"unit_num": txtUnitNo.value},{"job_num": txtJobNo.value},{"date_completed": dateInspected.value});
delete lstvw.ga_questions;
InsertGA.trigger();
return lstvw;


1 Like

Thanks for sharing your solution! :tada:

1 Like