Question

Mass Update button

  • 2 December 2020
  • 7 replies
  • 330 views

Userlevel 3
Badge +9

On the Tech Portal, I am using the ‘Mass Update’ button on the Task list screen to update tasks in bulk.  The issue I have is not being able to ‘save’ the changes to this list.  I have tried saving changes via the client script attached to the button, and also via a ‘Save’ button on that screen, nothing works.  Anyone know why? or have an example of how to use the ‘Mass Update’ button feature?

Just to confirm, this is on the Task List (Search results) screen in the Tech Portal, not the Task detail screen which shows the details of the one selected task.


This topic has been closed for comments

7 replies

Userlevel 7
Badge +24

Hi @MartinF,

From what you have put here I would think this is likely a bug that would be best investigated under a case. I think this may have already been logged as such? 

Kind regards,

Lee Pinchbeck

Userlevel 3
Badge +9

Hi @Lee Pinchbeck ,

 

I had logged it as an issue as you mention, but it just got closed without being looked into.  Could you reopen it and flag it for further investigation please? the case number is G2223178

Thanks, Martin

Userlevel 7
Badge +24

Hi @MartinF,

Dug through the case notes and looks like it was out of scope as it needs code correcting which is valid (I thought it was complete script that was not being registered by the portal).

If you post the code here though there may be some forum users that are able to assist in getting it up and running. @AdrianEgley @Mike The FSM TechnoGeek Are you able to help?

Kind regards,

Lee Pinchbeck

Userlevel 3
Badge +9

@Lee Pinchbeck@AdrianEgley@Mike The FSM TechnoGeek 

Heres the script, the commented out section is where i tried it with an update statement.  The issue is purely that it will not save the changes (They update on the screen).  A Save button added to the screen also did not work.

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

if(confirm(getMessage('MF_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);
  
 }

Userlevel 5
Badge +17

The code you have commented out is for mobile.  Since you’re working with the Tech Portal, which is essentially a cross section of the Web Client, you’ll need to use client scripting functions for the Web Client instead.  Try this:

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

if(confirm(getMessage('MF_BULK_COMPLETE_CONFIRM','Information')))
{
var requestsToBatch = new Array();
for (var rowIndex = 0; rowIndex < size(rows); ++rowIndex)
{
var row = rows[rowIndex];

var status=row.data['task.user_def2'];
if(status=='Y')
{
var request = createInsertUpdateRequest('task', { task_id: row.task_id, task_status: 'COMPLETED' });
arrayPush(requestsToBatch, request);

setValueOnListDataRow(row,'task','task_status','COMPLETED');

noTasksToComplete=noTasksToComplete+1;
}
}

if(size(requestsToBatch) > 0)
{
var batchUpdateRequest = createSequentialIndependentBatchRequest(requestsToBatch);
executeRequest(batchUpdateRequest);
}

saveChanges();
alert("Tasks bulk completed: "+noTasksToComplete);
}

return true;

 

Userlevel 3
Badge +9

Hi @Mike The FSM TechnoGeek

 

Thanks for the reply, however it doesn't seem to work for me.  I cant see why, your code seems to make sense.  Does the batch update need a commit action maybe?

Userlevel 5
Badge +17

Martin, I’m not sure what to tell you.  I looked this over again, and I don’t see what is wrong.  Admittedly, I am pretty biased because I wrote it!  You really don’t need anything more for the database transaction after the call to executeRequest().

The only thing I can suggest is using the alert() function to validate that the data being referenced is correct.  For example, is row.task_id returning the expected value?  I’m also assuming you’re using FSM 6 update 6?