How to update/edit form value?

I want to edit comment input inside my camunda form but when i try to make this ( i mean when i write something new instead of “comment” value) i got this error:

TypeError: Cannot set property ‘value’ of undefined
at d.variableValue (camunda-tasklist-ui.js?bust=7.8.0:6)
at Array.eval (eval at (camunda-tasklist-ui.js?bust=7.8.0:5), :32:30)
at c.g.trigger (camunda-tasklist-ui.js?bust=7.8.0:6)
at c.CamundaForm.fireEvent (camunda-tasklist-ui.js?bust=7.8.0:6)
at d (camunda-tasklist-ui.js?bust=7.8.0:5)
at camunda-tasklist-ui.js?bust=7.8.0:5
at Object.invoke (deps.js?bust=7.8.0:26962)
at c.fireEvent (camunda-tasklist-ui.js?bust=7.8.0:5)
at c.CamundaForm.submit (camunda-tasklist-ui.js?bust=7.8.0:6)
at Scope.s [as completionHandler] (camunda-tasklist-ui.js?bust=7.8.0:25)
here is my code:
var comments=$scope.comments=[];

    camForm.on('form-loaded', function() {
      // tell the form SDK to fetch the variable named 'document'
    camForm.variableManager.fetchVariable('selectedDocuments');
   console.log($scope.selectedDocuments);
    });
    camForm.on('variables-fetched', function() {
      // work with the variable (bind it to the current AngularJS $scope)
    //$scope.refusalComment = camForm.variableManager.variable('refusalComment').value;
     //console.log(camForm.variableManager.variable('refusalComment').value);   
     $scope.selectedDocuments =addComment(camForm.variableManager.variableValue('selectedDocuments'));
      
    });
 camForm.on('submit', function(evt) {
    for(var i=0;i<Object.keys($scope.selectedDocuments).length;i++){
     if($scope.selectedDocuments[i].refusalComment!=='comment'){

        $scope.comments.push($scope.selectedDocuments[i]);
       
    }
    }

    if($scope.comments.length==0){
      camForm.variableManager.variableValue('selectedDocuments',$scope.selectedDocuments);
    }else {
      console.log($scope.comments);
     camForm.variableManager.variableValue('comments',$scope.comments);
}
     
});

function addComment(data){
var json=$scope.json={};
var json1=$scope.json1={};
json=JSON.parse(data);
json1=json.FinalResult;
json1=JSON.parse(json1);
for(var  i=0;i<Object.keys(json1).length;i++){
json1[i].refusalComment="comment";
}
console.log(json1);
return json1;
}
function ConvertToJsonArray(arr){
//I  have  replaced FinalResult with data
var  jsonArray=[];
var json=$scope.json={};
var json1=$scope.json1={};
var json2=$scope.json2={};
json=JSON.parse(arr);
json1=json.FinalResult;
json2=JSON.parse(json1);

return json2;
}
function EnrichValue(data,comment){
var json=$scope.json={};
var json1=$scope.json1={};
json=JSON.parse(data);
json1=json.FinalResult;
json1=JSON.parse(json1);
for(var  i=0;i<Object.keys(json1).length;i++){
json1[i].comment=comment;
}
console.log(json1);
return json1;
}

what should i change to get rid of this error?
@kristin you are always helpfull to me , Do you have any idea about it?

Hi @Sally,

Are you sure, that the following lines aren’t still active?

This is the only part of the code you use “.vlaue” which refers to your error.

regards,
Dominik

I have added comment on them so they shouldn’t be active