My database structure:
const data = {
“students”: [
{
“id”: 1,
“name”: “Alice”,
“course”:
{“code”: “CS101”, “title”: “Intro to Programming”}
},
{
“id”: 2,
“name”: “Bob”,
“course”:
{“code”: “PH101”, “title”: “Physics I”}
}
]
};
Where “course” is a list of courses from the database: [
{“code”: “MA202”, “title”: “Linear Algebra”,
“code”: “CS201”, “title”: “Data Structures”,
“code”: “PH101”, “title”: “Physics I”,
“code”: “CS101”, “title”: “Intro to Programming”} ]
On the front end, I’m displaying a table with a list of Students showing Id, Name and Course (as a dropdown listing all the Courses offered but with the Default Value of the Student’s course ie: Alice’s dropdown would default to Intro To Programming) .
I’m trying to let the user change the selected Student’s “course” by clicking another course in the Courses Dropdown. I want to record the change on the client side using a custom state of a list of Students (cs_Students) defined on my page level.
Using the toolbox’s javascript to bubble workflow, why does this code still return the original value?
let newArray=;
let selectedindex=Current row’s index -1;
newArray=properties.paramlist1.get(0,properties.paramlist1.length()); //Paramlist1 is set to MyPage’s cs_Students
newArray[selectedIndex].course= This Dropdown’s Value;
bubble_fn_test(newArray); //This is suppose to return an array of Students with the new course but instead it returns the original array of Students with nothing changed.
Even if I display the Student’s “name” in an input element within the table of Students, and allow the user to change the name to trigger the javascript workflow, I still get the original array with nothing changed when I add the following line to the above code:
newArray[selectedIndex].name= “Kevin”;
Is this how you change the value of a nested object using javascript to bubble in a workflow?