I want to use my camunda variables (for example ‘processID’ or other variables from Modelling) in javascript. With:
<script cam-script type="text/form-script">
var variableManager = camForm.variableManager;
camForm.on('form-loaded', function() {
// fetch the variable 'customVariable'
variableManager.fetchVariable('value');
});
camForm.on('variables-fetched', function() {
// access to all process variables after the form has loaded
$scope.value = variableManager.variable('value');
});
</script>
I can load them and print to console. But I want to use them in an other javascript file. Is that ppssible?
in my process I have variables, for example for a euro value. Depending on this amount other values have to be loaded by REST. I did not manage to read this process instance dependent value.
with the code you mentioned above you can get the variables from Camunda.
Once the variables are fetched, in the callback function you can define what should happen:
camForm.on('variables-fetched', function() {
// access to all process variables after the form has loaded
$scope.value = variableManager.variable('value');
// add your rest call here.....
if ($scope.value === 'eur') {
}
});