Update a process variable

Hi ,

I want to update an existing process variable value.

My scenario is a review task.In which a form will be rejected and user has to be review and rectify the suggestions.

For that i have fetched the value on form load and displayed in view. When submitting i have created variable for the same.

I got error as “Error: Cannot add variable with name items: already exists”.

My Code :

On Form Load

camForm.variableManager.fetchVariable('items');

camForm.on('variables-fetched', function() {
    $scope.items =camForm.variableManager.variableValue('items');
}

After updating

camForm.on(‘submit’, function(evt) {

        camForm.variableManager.createVariable({
            name: 'items',
            type: 'json',
            value: $scope.items,
            isDirty: true
        });

})
Is there any method to update existing variable ?

Hi @Ajr,

You could try to update the variable as follows:

camForm.on('submit', function() {
  $scope.items =camForm.variableManager.variableValue('items', $scope.items);
}

But I am not sure, why do you want to update the value of the variable? I think, this should not be necessary.

Cheers,
Roman

1 Like