1

I am customizing Anywhere(7.5.2)-WorkExecution. I am trying to create a dynamic list on the Work Log execution but it always creates only one. Kindly help.

CREATE Action

Work Log

File: WorkLogHandler.js Function: _saveTransaction

Existing Code:

_saveTransaction: function(){
try{
      var workOrderSet = CommonHandler._getAdditionalResource(this,"workOrder");
      var workOrder = workOrderSet.getCurrentRecord();
if (!workOrder.isNew()) {
ModelService.save(workOrderSet);
} 
this.ui.hideCurrentView();
}catch(e){
throw e;
}
},

New Code:

_saveTransaction: function(){
debugger;
try{
      var workOrderSet = CommonHandler._getAdditionalResource(this,"workOrder");
      var workLogdata = CommonHandler._getAdditionalResource(this,'workOrder.workloglist').getCurrentRecord();
      var workOrder = workOrderSet.getCurrentRecord();
      debugger;

      for(var i=0; i<2; i++){
      debugger;
      if (!workOrder.isNew()) {
     debugger;
     workLogdata.set('summary',i+" Round");
     } 
      ModelService.save(workLogdata);
     this.ui.hideCurrentView();
      }
return;
}catch(e){
throw e;
}

},
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Vignesh
  • 375
  • 1
  • 2
  • 13

1 Answers1

0

If you're trying to create a new worklog entry every time the record is saved, the issue is here..

var workLogdata = CommonHandler._getAdditionalResource(this,'workOrder.workloglist').getCurrentRecord();

You need to create a new record for each new worklog that you're trying to add, not retrieve the current one.

var workLogdata = CommonHandler._getAdditionalResource(this,'workOrder.workloglist').createNewRecord()

scott dickerson
  • 908
  • 1
  • 5
  • 13
  • Thanks a lot for the quick response. I tried the same but getting an new issue that for the second iteration, the LOGTYPE becomes NULL Also, It doesn't saved in Maximo Asset Management as well. Please help. – Vignesh Jan 14 '16 at 02:44