Hi everyone,
I don't know how to proceed and need some help. Once I click on a button, I run a script that is basically working through all the necessary elements to get the values and save them into my mySQL database.
The question is a simple text that will be saved. The same goes for the answer.
Only categories is a multiselect, which I get as an array and I'm not sure how to implement it in retool, so that I can save the chosen categories with a query in my database.
That's how my script looks like.
// (1) save question
save_question.trigger();
// (2) get last insert id from MySQL
var question_id = get_last_insert_id.trigger();
// (3) save question and category
// for each category we need to save one row
var categories = neue_frage_kategorien.value;
let question = get_last_insert_id.trigger();
categories.forEach( function(category) {
save_questions_categories.trigger({
additionalScope: {
questionId: question_id,
categoryId: category
}
})});
// (4) save answer
save_answer.trigger(neue_frage_antwort.value, question_id);
I get a message error, saying the following:
Error:`trigger` options must be an object neue_frage_speichern
in run script(neue_frage_speichern)
in neue_frage_speichern click event handler(neue_frage_speichern)
from user interaction
And I'm not sure what I'm doing wrong.