I want to add my selectedDocuments object ‘comment’ item with it’s value (so that i want to show this input in a form where this selectedDocuments object values are rendered and after submmiting this input i want it to be added to selectedDocuments object ) i have tried several varaints here is my code:
var variableManager = camForm.variableManager;
$scope.refusalComment=null;
camForm.on('form-loaded', function() {
// tell the form SDK to fetch the variable named 'document'
variableManager.fetchVariable('selectedDocuments');
});
camForm.on('variables-fetched', function() {
// work with the variable (bind it to the current AngularJS $scope)
$scope.refusalComment = variableManager.variable('refusalComment').value;
console.log( $scope.refusalComment+"=========refusalComment==========");
$scope.selectedDocuments =ConvertToJsonArray(variableManager.variable('selectedDocuments').value);
});
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);
//console.log(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;
}
and here is my embedded form code:
>
<div class="control-group" > <label for="id" class="control-label">code</label> <div class="controls"> <input id="id" class="form-control" type="text" ng-model="item.id" required readonly/> </div> </div> <div class="control-group" > <label for="cardNumber" class="control-label">number </label> <div class="controls"> <input id="cardNumber" class="form-control" type="text" ng-model="item.cardNumber" required /> </div> </div> <div class="control-group" > <label for="organizationNameGE" class="control-label" >name</label> <div class="controls"> <input id="organizationNameGE" class="form-control" type="text" ng-model="item.organizationNameGE" required /> </div> </div> <div class="control-group" > <label for="organizationNameEN" class="control-label">write comment </label> <div class="controls"> <input id="comment" class="form-control" type="text" cam-variable-name="comment" cam-variable-type="String" value="write comment" /> </div> </div> </div> <div class="container"> <div class="control-group" > <label for="approved" class="control-label">approve</label> <input type="checkbox" id="approved" class="form-control" cam-variable-name="approved" cam-variable-type="Boolean"/> </div> </div> </form>
when i run this code i always got this error cann’t get value of undefined ( i mean comment)
what should i cjange to make this code work?