Skip to main content

I am trying to access the list data in the ‘task’ list on the ‘My Tasks Today’ page on the Tech Portal.  I have tried:

 

var listData=getFormDataLists('task');
var listLength=listData.length;
alert(listLength);

 

But this just returns 0, when there are tasks there?

 

What i am trying to do is retrieve the tasks, then cycle through them and then performing a dirty read on a checkbox i have added (user_def2), any that are checked will then be updated.

Hi Martin,

 

Hope that you are trying to retrieve values from the search result set? Have you tried this way to get the number of active tasks once the tasks are loaded?

var rows = getSearchResultDataTableRows();

alert(rows .length);

for (var rowIndex = 0; rowIndex < size(rows); ++rowIndex)
{
    var row = rowsnrowIndex];
    
        var status=row.datar'task.user_def2'];
        if(status=='Y')
        
        {
           //do something
        }
    }
}

Regards,

SAAALK


Hi,

I have used the above code and it does what I need in terms of reading the list items.  Now I am trying to update them.  It is a list of tasks which I want to set the status to complete in bulk.  I can get the value to change on the form but not commit to the db.  Here is the code I have been trying with (you can see from the comments the various attempts) Any idea how to get this working?  This is being run in the TechPortal

 

var rows = getSearchResultDataTableRows();
var noTasksToComplete=0;

if(confirm(getMessage('BULK_COMPLETE_CONFIRM','Information')))
 {
  for (var rowIndex = 0; rowIndex < size(rows); ++rowIndex)
  {
      var row = rows>rowIndex];
      
          var status=row.data 'task.user_def2'];
          if(status=='Y')
          
          {
               var taskId=row.dataÂ'task.task_id'];
               //var rowId = getDBValue(stringFormat("select metrix_row_id from task where task_id = {0}", taskId));
               //Set Status
                //var taskStatusTrans = generateDataTransaction("task", "UPDATE", stringFormat("metrix_row_id = {0}", rowId));
               //taskStatusTrans = addToDataTransaction(taskStatusTrans, "metrix_row_id", rowId);
               //taskStatusTrans = addToDataTransaction(taskStatusTrans, "task_id", taskId);
               //taskStatusTrans = addToDataTransaction(taskStatusTrans, "task_status", "COMPLETED");
               //taskStatusTrans = addToDataTransaction(taskStatusTrans, "modified_dttm", currentDate);
               //taskStatusTrans = addToDataTransaction(taskStatusTrans, "modified_by", personId);
               //saveDataTransaction(taskStatusTrans, getMessage("Task", "STATUS"));
     
               //setDBValue("update task set task_status='COMPLETED' where task.taskid={0}",taskId);
               //setDBValue("update task set task_status='COMPLETED' where task.taskid="+taskId);
           
               setValueOnListDataRow(row,'task','task_status','COMPLETED');
           
            noTasksToComplete=noTasksToComplete+1;
          }
      
  }
   
  saveChanges();
  alert("Tasks bulk completed: "+noTasksToComplete);
  
 }


Reply