I have an app with a table of to-do tasks. When you click a row the values of the task are populated into a container below which is to be a form to edit the tasks.
Youtube video of problem with naration
The way I have set it up, on row click it runs a javascript control query which runs code like this for all the values....
localStorage.setValue("task_id", table1.selectedRow.data['t.task_id']);
textInput2.setValue(localStorage.values.task_id);
This grabs the values from the table, sends it to localStorage, then pulls it from local storage to populate the test field in the form.
So as I said it's always giving me the 2nd to last thing I clicked even after I run localStorage.clear() and reload the page.
IF I click the same row more than once it trickles down as now the 2nd to last is the same as the last.
I have tried 15 second delays to make sure asynchronous code is not firing off out of the assumed order. It makes now difference.
I have diagnostic fields tween the 2 tables so you can see in the gif that the localStorage is updated seconds before I try to update fields.
Happens in Firefox and Chrome.
Below you can see the function that runs when I click a row.
LMK if I can provide more info. Thanks!
function first() {
// FROM table TO ls
localStorage.setValue("task_id", table1.selectedRow.data['t.task_id']);
localStorage.setValue("saop_id", table1.selectedRow.data['t.sales_opportunity_id']);
localStorage.setValue("saop_name", table1.selectedRow.data['so_name']);
localStorage.setValue("cust_name", table1.selectedRow.data['ec.name']);
localStorage.setValue("cust_id", table1.selectedRow.data['so.customer_id']);
localStorage.setValue("emp_name", table1.selectedRow.data['ee.name']);
localStorage.setValue("emp_id", table1.selectedRow.data['so.employee_id']);
localStorage.setValue("emp_in", table1.selectedRow.data['employee_initials']);
localStorage.setValue("t_desc", table1.selectedRow.data['t.description']);
localStorage.setValue("t_completed_at", table1.selectedRow.data['t.completed_at']);
}
function second() {
// FROM ls TO view
textInput2.setValue(localStorage.values.task_id);
textInput4.setValue(localStorage.values.saop_id);
textInput5.setValue(localStorage.values.saop_name);
textInput8.setValue(localStorage.values.cust_name);
textInput6.setValue(localStorage.values.cust_id);
textInput9.setValue(localStorage.values.emp_name);
textInput7.setValue(localStorage.values.emp_id);
textInput12.setValue(localStorage.values.emp_in);
textInput3.setValue(localStorage.values.t_desc);
}
function third() {
// FROM ls TO view (Set completed)
lenTest = localStorage.values.t_completed_at += 1;
if ( lenTest.length > 1)
{
checkbox1.setValue(true);
localStorage.setValue("checkVal", 'Completed '+localStorage.values.t_completed_at);
}
else
{
checkbox1.setValue(false);
localStorage.setValue("checkVal", 'Incomplete');
}
localStorage.setValue("t_dcpt_id", table1.selectedRow.data['t.daisy_chain_parent_task_id']);
textInput13.setValue(localStorage.values.t_dcpt_id);
}
function fourth() {
utils.showNotification({ title: 'table1.selectedRow.data[\'t.task_id\'] '+table1.selectedRow.data['t.task_id'], description:'desc-info', notificationType: 'info'})
utils.showNotification({ title: 'localStorage.values.task_id ' +localStorage.values.task_id, description:'desc-info', notificationType: 'info'})
utils.showNotification({ title: 'textInput2.value ' +textInput2.value, description:'desc-info', notificationType: 'info'})
}
setTimeout(function () { first(); }, 0);
setTimeout(function () { second(); }, 3000);
setTimeout(function () { third(); }, 3000);
//setTimeout(function () { fourth(); }, 4000);