Access ALL parent Process Variables within subprocess on embedded forms?

655 views
Skip to first unread message

Melissa Palmer

unread,
Jan 27, 2015, 7:18:17 AM1/27/15
to camunda-...@googlegroups.com
Hi 

Is it possible to access all parent process variables on a "User Task" within a subprocess... using an embedded forms? 

Use Case: Super Process callActivity has "<camunda:in variables="all"/>" set. However within the embedded form you HAVE to fetch the variable from camForm.variableManager and assign it to the $scope something as below: 
<form role="form" name="myForm">
     <script cam-script type="text/form-script">

        var variableManager = camForm.variableManager;

        camForm.on('form-loaded', function() {
            camForm.variableManager.fetchVariable('additionalComments');
            camForm.variableManager.fetchVariable('superProcessInstanceId');
            camForm.variableManager.fetchVariable('superProcessName');
            camForm.variableManager.fetchVariable('superProcessDescription');


            console.log("form-loaded:: camForm.variableManager: ", camForm.variableManager);
            console.log("form-loaded:: variableManager: ", variableManager);          
        });
        camForm.on('variables-restored', function() {
            $scope.additionalComments = camForm.variableManager.variableValue('additionalComments');
            $scope.superProcessInstanceId = camForm.variableManager.variableValue('superProcessInstanceId');
            $scope.superProcessName = camForm.variableManager.variableValue('superProcessName');
            $scope.superProcessDescription = camForm.variableManager.variableValue('superProcessDescription');

            console.log("variables-restored:: camForm.variableManager: ", camForm.variableManager);
            console.log("variables-restored:: variableManager: ", variableManager);
            console.log("setting variables to scope");
        });
  </script>
  
    <div class="form-group">
        
        Finance Approval for:  {{superProcessName}}
        Finance Approval Description:  {{superProcessDescription}}
     
        
        <BR/>
        additionalComments:: {{additionalComments}}         
    </div>
</form>


QUESTIONS?
1) Is it possible to get a list of all super process variables without the need to fetch and assign to $scope within JavaScript? 
2) The example I am looking at would be an approval task.. thus within the subprocess we want to be able to show current user (dynamically) the variables/parameters which where selected within SuperProcesses... is there possibly a way to do this via History/Audit information? 


Thanks
Melissa

Sebastian Stamm

unread,
Jan 27, 2015, 11:21:48 AM1/27/15
to camunda-...@googlegroups.com
Hi Melissa,

you can use the REST-API to retrieve all variables which are visible to a task [1]. The corresponding Javascript would look something like this:

  <script cam-script type="text/form-script">
    inject
(['$http', 'Uri', function($http, Uri) {
      camForm
.on('form-loaded', function() {
        $http
.get(Uri.appUri("engine://engine/:engine/task/" + camForm.taskId + "/form-variables")).success(function(result){
          angular
.forEach(result, function(value, key) {
            $scope
[key] = value;
         
});
       
});
     
});
   
}]);
 
</script>

  
Does this help?

Cheers
Sebastian

Daniel Meyer

unread,
Jan 27, 2015, 11:30:49 PM1/27/15
to camunda-...@googlegroups.com
Hi,

To me this sounds like a requirement for which we should have an out of the box solution. Ie. some kind of API which you can invoke on the camForm object and causes all variables to be fetched.

camForm.on('form-loaded', function() {
  camForm
.variableManager.fetchAllVariables();
});


@Sebastian what do you think?

Daniel

Sebastian Stamm

unread,
Jan 28, 2015, 3:55:28 AM1/28/15
to camunda-...@googlegroups.com
Hi Daniel,

this is a good idea. I created a feature request for this: https://app.camunda.com/jira/browse/CAM-3386

Sebastian

Melissa Palmer

unread,
Jan 28, 2015, 5:50:06 AM1/28/15
to camunda-...@googlegroups.com
Thanks Sebastian/Daniel, yes that has helped. And look foward to being able to user the variableManage with a simple function to do this. Regards Melissa
Reply all
Reply to author
Forward
0 new messages