Loading previous data in process start form

@Wagner-Otto_Wutzke here is a example i hacked together.

It is functional, but would refer back to Camunda team to see if this is fully “legit” and if any problems come about for doing this:

Form:

<form role="form">

  <textarea cam-variable-name="testText"
            cam-variable-type="String"
            placeholder="Test Text placeholder" />
  </textarea>
  <br>
  <select
      cam-variable-name="selectedValue"
      cam-variable-type="String"
      ng-model="myOption"
      ng-options="value.id as value.text group by value.text for value in myOptions">
      <option>--</option>
  </select>

  <script cam-script type="text/form-script">
    //Note that the "value" of the returned selected item in the <select> will be 0, 1, 2....

    inject([ '$scope', '$http', 'Uri', function($scope, $http, Uri) {
      camForm.on('form-loaded', function() {
        var deploymentId = camForm["options"]["deploymentId"];

        function jsonFileNeeded(value) {
          return value["name"] == "data.json";
        }

          $http.get(Uri.appUri('engine://engine/:engine/deployment/' + deploymentId + '/resources')).
                        success(function(data) {

                             var jsonResourceId = data.filter(jsonFileNeeded)[0]["id"];

                             $http.get(Uri.appUri('engine://engine/:engine/deployment/' + deploymentId + '/resources/' + jsonResourceId + '/data')).
                                         success(function(data) {
                                              // var jsonFile = data;
                                              $scope.myOptions = data;
                                              // console.log(camForm);
                                            });
                        });
    });
  }]);

  </script>
</form>

JSON File:

[
  {
    "id": "id0",
    "text": "text0"
  },
  {
    "id": "id1",
    "text": "text1"
  }
]

data.json (95 Bytes)

form.html.xml (1.6 KB)

externalJsonTest.bpmn (2.9 KB)

change the html.xml file back to .html.

Deploy with something like:

curl -w "\n" --cookie cookie.txt \
-H "Accept: application/json" \
-F "deployment-name=rest-test" \
-F "enable-duplicate-filtering=false" \
-F "deploy-changed-only=falses" \
-F "externalJsonTest.bpmn=@/PATH_TO_FILE/externalJsonTest.bpmn" \
-F "form.html=@/PATH_TO_FILE/ExternalJSONTest/form.html" \
-F "data.json=@/PATH_TO_FILE/ExternalJSONTest/data.json" \
http://CAMUNDA_SERVER_LOCATION:8080/engine-rest/deployment/create
1 Like