Inside a form script, the following built-in variables and functions are available:

camForm

The camForm variable is an instance of the CamSDK.Form class. It is the primary access point tothe form API and allows definition of event handers for participation in the form lifecycle:

  1. <form role="form">
  2. ...
  3. <script cam-script type="text/form-script">
  4. var variableManager = camForm.variableManager;
  5. camForm.on('variables-fetched', function() {
  6. // access to all process variables after the form has loaded
  7. console.log(variableManager.variables);
  8. });
  9. </script>
  10. </form>

$scope

Only available with AngularJS integration.

Provides access to the current AngularJS scope:

  1. <form role="form">
  2. <input type="text"
  3. cam-variable-name="CUSTOMER_ID"
  4. cam-variable-type="String"
  5. ng-model="customerId" />
  6. <script cam-script type="text/form-script">
  7. camForm.on('variables-applied', function() {
  8. // the input field is bound to $scope.customerId
  9. $scope.customerId = "some-id";
  10. });
  11. </script>
  12. </form>

inject()

Only available with AngularJS integration.

  1. <form role="form">
  2. <script cam-script type="text/form-script">
  3. inject(['$http', 'Uri', function($http, Uri) {
  4. camForm.on('form-loaded', function() {
  5. // use injected $http service for making requests, e.g.
  6. $http.get(Uri.appUri('engine://engine/:engine/task/' + camForm.taskId)).success(function(task) {
  7. $scope.task = task;
  8. });
  9. });
  10. }]);
  11. </script>
  12. </form>

原文: https://docs.camunda.org/manual/7.9/reference/embedded-forms/javascript/api/