Available API
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 to
the form API and allows definition of event handers for participation in the form lifecycle:
<form role="form">
...
<script cam-script type="text/form-script">
var variableManager = camForm.variableManager;
camForm.on('variables-fetched', function() {
// access to all process variables after the form has loaded
console.log(variableManager.variables);
});
</script>
</form>
$scope
Only available with AngularJS integration.
Provides access to the current AngularJS scope:
<form role="form">
<input type="text"
cam-variable-name="CUSTOMER_ID"
cam-variable-type="String"
ng-model="customerId" />
<script cam-script type="text/form-script">
camForm.on('variables-applied', function() {
// the input field is bound to $scope.customerId
$scope.customerId = "some-id";
});
</script>
</form>
inject()
Only available with AngularJS integration.
<form role="form">
<script cam-script type="text/form-script">
inject(['$http', 'Uri', function($http, Uri) {
camForm.on('form-loaded', function() {
// use injected $http service for making requests, e.g.
$http.get(Uri.appUri('engine://engine/:engine/task/' + camForm.taskId)).then(function(task) {
$scope.task = task;
});
});
}]);
</script>
</form>