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.
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;
}
},
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()