@fabiobalsamo wrote:
Hi why i can't do the Update in the Table????? Where is my error??
$scope.chiamataUno = function() {
var authdata = Base64.encode("DEMVSINT_ADMIN" + ":" + "Password01");
$http.defaults.headers.common["Authorization"] = "Basic " + authdata;
$http.get('http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/P8BPMREST/p8/bpm/v1/queues/DV_ResponsabileBSDL/workbaskets/Responsabile BSDL/queueelements/?cp=DCMSVS_CONN1').success(function(response) {
console.log(response);$rootScope.rispostaUno = response.queueElements; $rootScope.risposta = response; $rootScope.responseJSON = JSON.stringify($scope.risposta); var newArray = []; $rootScope.newObjectJSON = []; $scope.newObject = [];
for(var i=0; i < response.queueElements.length;i++){
var newObject = {
//forse togliere elementi e columns
//elementi:response.queueElements[i],
caseFolderId:response.queueElements[i].caseFolderId.replace("{","").replace("}",""),
caseTaskId:response.queueElements[i].caseTaskId,
stepName:response.queueElements[i].stepName,
columns:response.queueElements[i].columns,
DV_Caseidentifier_for_eni_OdA: response.queueElements[i].columns.DV_Caseidentifier_for_eni_OdA,
DV_EBELP_ODA: response.queueElements[i].columns.DV_EBELP_ODA,
DV_EINDT_ODA: response.queueElements[i].columns.DV_EINDT_ODA,
DV_MATNR_TXZ01_POS_ODA: response.queueElements[i].columns.DV_MATNR_TXZ01_POS_ODA,
DV_NAMECL_POS_ODA: response.queueElements[i].columns.DV_NAMECL_POS_ODA,
DV_NETPR_WAERS_POS_ODA: response.queueElements[i].columns.DV_NETPR_WAERS_POS_ODA,
DV_PEINH_POS: response.queueElements[i].columns.DV_PEINH_POS,
DV_MENGE_MEINS_POS_ODA: response.queueElements[i].columns.DV_MENGE_MEINS_POS_ODA
};$rootScope.newObjectJSON.push(JSON.stringify(newObject)); //console.log("rootScope.newObjectJSON " + $rootScope.newObjectJSON); //console.log("dettaglio " + newObject.DV_MENGE_MEINS_POS_ODA + " " + newObject.stepName + " " + newObject.DV_EINDT_ODA); newArray.push(newObject); var queryOdlClone = "SELECT caseTaskId FROM Tabella_OdL_Temp WHERE caseTaskId = '"+ newObject.caseTaskId + "'"; $cordovaSQLite.execute(db, queryOdlClone, []).then(function(resQuery) { if(resQuery.rows.length > 0) { var query = "UPDATE Tabella_OdL_Temp SET caseTaskId = '"+ newObject.caseTaskId + "',caseFolderId = '"+ newObject.caseFolderId + "', stepName = '"+ newObject.stepName + "', DV_Caseidentifier_for_eni_OdA = '"+ newObject.DV_Caseidentifier_for_eni_OdA + "', DV_EBELP_ODA = '"+ newObject.DV_EBELP_ODA + "', DV_EINDT_ODA = '"+ newObject.DV_EINDT_ODA + "', DV_MATNR_TXZ01_POS_ODA = '"+ newObject.DV_MATNR_TXZ01_POS_ODA + "', DV_NAMECL_POS_ODA = '"+ newObject.DV_NAMECL_POS_ODA + "', DV_NETPR_WAERS_POS_ODA = '"+ newObject.DV_NETPR_WAERS_POS_ODA + "', DV_PEINH_POS = '"+ newObject.DV_PEINH_POS + "', DV_MENGE_MEINS_POS_ODA = '"+ newObject.DV_MENGE_MEINS_POS_ODA + "', Approvata = 0, Rifiutata = 0, Archiviata= 0 WHERE caseTaskId = ?"; $cordovaSQLite.execute(db, query, [newObject.caseTaskId]).then(function(res) { console.log("UPDATE TAB UNO"); }, function(error) { console.error(error); }); }else{ var queryOdl = "INSERT INTO Tabella_OdL_Temp (caseTaskId, caseFolderId, stepName, DV_Caseidentifier_for_eni_OdA,DV_EBELP_ODA,DV_EINDT_ODA,DV_MATNR_TXZ01_POS_ODA,DV_NAMECL_POS_ODA,DV_NETPR_WAERS_POS_ODA,DV_PEINH_POS,DV_MENGE_MEINS_POS_ODA, Approvata, Rifiutata, Archiviata) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $cordovaSQLite.execute(db, queryOdl, [newObject.caseFolderId.replace("{","").replace("}","") === null ? "null" : newObject.caseFolderId.replace("{","").replace("}",""), newObject.caseTaskId === null ? "null" : newObject.caseTaskId,newObject.stepName === null ? "null" : newObject.stepName, newObject.DV_Caseidentifier_for_eni_OdA === null ? "null" : newObject.DV_Caseidentifier_for_eni_OdA,newObject.DV_EBELP_ODA === null ? "null" : newObject.DV_EBELP_ODA,newObject.DV_EINDT_ODA === null ? "null" : newObject.DV_EINDT_ODA,newObject.DV_MATNR_TXZ01_POS_ODA === null ? "null" : newObject.DV_MATNR_TXZ01_POS_ODA,newObject.DV_NAMECL_POS_ODA === null ? "null" : newObject.DV_NAMECL_POS_ODA,newObject.DV_NETPR_WAERS_POS_ODA === null ? "null" : newObject.DV_NETPR_WAERS_POS_ODA,newObject.DV_PEINH_POS === null ? "null" : newObject.DV_PEINH_POS,newObject.DV_MENGE_MEINS_POS_ODA === null ? "null" : newObject.DV_MENGE_MEINS_POS_ODA, 0, 0, 0]).then(function(result) { console.log("insert"); }, function(error) { console.error(error); }); } });
}
//end for response.queueElementsfor(var j = 0; j < newArray.length; j++){ if(newArray[j].stepName !== "Item details"){ var casefolderId = newArray[j].caseFolderId.replace("{","").replace("}",""); chiamatadue.push('http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/CASEREST/v1/case/'+ casefolderId +'?TargetObjectStore=CM_DCMSVS_TGT_OBJ'); } } alert("call 2"); $scope.chiamataDueNuova();
}) .error(function(response) {
alert("ERROR");
});}
Posts: 1
Participants: 1