Save to engine camunda( version 7.9) variable type 'Date'
Clash Royale CLAN TAG#URR8PPP
Save to engine camunda( version 7.9) variable type 'Date'
I want to save variable 'beauftragungsdatum' type 'Date' to engine :
inject(['$http', 'Uri', function($http, Uri)
camForm.on('store', function(evt)
evt.retrieveVariables()
var varManager = evt.variableManager;
var vars = varManager.variables;
var dataVar = $scope.beauftragungsdatum;
varManager.variableValue('beauftragungsdatum', dataVar);
var variableData = ;
for(var v in vars)
if(varManager.isDirty(v))
var val = vars[v].value;
if(varManager.isJsonVariable(v))
val = JSON.stringify(val);
variableData[v] =
value: val,
type: vars[v].type,
valueInfo: vars[v].valueInfo
;
var data = modifications: variableData ;
var config =
headers :
'Content-Type': 'application/json'
;
$http.post(Uri.appUri('engine://engine/:engine/task/' + camForm.taskId + '/variables'), data, config);
evt.storePrevented = true;
);
]);
At the save moment I have a problem : variable 'beauftragungsdatum' is not type of date. I found out that var have wrong format. I fixed it and paste some decision:
inject(['$http', 'Uri', function($http, Uri)
camForm.on('store', function(evt)
evt.retrieveVariables()
var varManager = evt.variableManager;
var vars = varManager.variables;
var now=moment(dataVar).format("YYYY-MM-DDTHH:mm:ss.sssZZ");
console.log(now);
console.log(typeof now);
var d=varManager.variableValue('beauftragungsdatum');
console.log(d);
console.log(typeof d);
varManager.variableValue('beauftragungsdatum')=now;
var variableData = ;
for(var v in vars)
if(varManager.isDirty(v))
var val = vars[v].value;
if(varManager.isJsonVariable(v))
val = JSON.stringify(val);
variableData[v] =
value: val,
type: vars[v].type,
valueInfo: vars[v].valueInfo
;
var data = modifications: variableData ;
var config =
headers :
'Content-Type': 'application/json'
;
$http.post(Uri.appUri('engine://engine/:engine/task/' + camForm.taskId + '/variables'), data, config);
evt.storePrevented = true;
);
]);
As a result i have a problem attach file.
enter image description here
I need help in this question , may be know how save var 'Date' in Camunda 7.9.
1 Answer
1
In the following line, the value you are placing inside now
is a string:
now
var now=moment(dataVar).format("YYYY-MM-DDTHH:mm:ss.sssZZ");
The format
method returns a string in the format you specify.
format
if you want to get a Date object, use moment(dataVar).toDate()
.
moment(dataVar).toDate()
What line gives you the error exactly?
– Shai
Aug 6 at 10:16
I think here : varManager.variableValue('beauftragungsdatum', now) ;
– fin
Aug 6 at 11:26
You need to make sure. Try placing a breakpoint and see where and when the error occurs.
– Shai
Aug 6 at 12:00
Shai, say pls where I must pick breakpoint , I don't know
– fin
Aug 6 at 13:03
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Hi, Shai. You mean that i must write something like this: var now=moment(dataVar).toDate(); and after that: varManager.variableValue('beauftragungsdatum', now) ; As a result I have a problem : Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of java.util.Date from String value '2018-08-08T03:00:00.000Z': not a valid representation (error: Failed to parse Date value '2018-08-08T03:00:00.000Z': Unparseable date: "2018-08-08T03:00:00.000Z") at [Source: "2018-08-08T03:00:00.000Z"; line: 1, column: 1]
– fin
Aug 6 at 9:44