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
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
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
@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 = rowsrrowIndex];
     Â
          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);
 Â
 }
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.dataw'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;
Â
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?
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?