Writing JavaScript Expressions
Docupace Start has a very flexible functionality because it allows writing JavaScript code for many parts of the wizard that you are building. You may define JavaScript functions in wizard onLoad actions, in onExit event handlers, in page onEnter actions, then use these functions and references to objects within the wizard in validation rules, in conditions for fields, within Rich Text fields, and many other places.
Many fields in Docupace Start will allow you to use or show values from the wizard’s objects. This is described in-depth in the How to Access Meta Field Values section.
To access these values, use double-bracketed interpolation with double curly braces on both sides of the value that you are referencing.
Examples:
{{wizardState.$createdWorkItem.id}}
{{startingPointData.mySearchWord}}
{{startingPointData['Owner1.FirstName'] + ' ' + startingPointData['Owner1.LastName']}}
{{startingPointData['Rep1.RepNumber']}}
Available JavaScript variables will differ depending on the field execution context. Please see the Field Execution Context reference section for objects, properties, and methods used within Docupace.
Important!
Names of objects and properties in JavaScript are case-sensitive. E.g. 'wizardstate'
and 'startingpointdata'
may not work, while 'wizardState'
and 'startingPointData'
will.
Methods, objects, functions used in Docupace Start JavaScript expressions:
window.connectApi = {};
//
window.connectApi.closeAppInIframe = function () {
$rootScope.documentViewerType='FORM';
$rootScope.$broadcast('reloadTaskDocuments');
$rootScope.reloadCurrentDocument();
window.location.reload();
};
//
window.connectApi.previewDocument = function (domainId, id) {
$rootScope.openDocumentNewWindow($rootScope.buildDocumentUrl(domainId, id));
};
//
window.connectApi.showFileUploadDialog = function(uploadOptions, uploaderSpecialOptions, onCompleteItemCallback) {
$rootScope.showFileUploadDialog(uploadOptions, uploaderSpecialOptions, onCompleteItemCallback)
};
//
window.connectApi.hideModalDialog = function() {
$rootScope.hideModalDialog();
};
//
window.connectApi.navigate = function (url, params) {
if(params) {
$location.path(url).search(params);
}
else if (url){
$location.path(url);
}
else {
$location.path();
}
};
//
window.connectApi.search = function (name, value) {
$location.search(name, value)
};
//
window.connectApi.getRouteParams = function () {
return $routeParams
};
//
window.connectApi.getModalDialogData = function () {
return $rootScope.modalDialogData;
};
//
window.connectApi.http = function () {
return $http;
};
//
window.connectApi.handleError = function (error) {
ErrorService.handleError(error);
};
//
window.connectApi.addAlert = function (alert) {
$rootScope.addAlert(alert);
};
//
window.connectApi.reload = function (params) {
if(params) {
var url = location.pathname;
url = url + "#" + $location.path();
url = url + "?" + $.param(params);
location.href=url;
location.reload();
}
else {
location.reload();
}
};
//
window.connectApi.disableThirdPartyAppConfirmationDialog = function () {
$rootScope.confirmationDialogEnabled = false;
};
//
window.connectApi.dataFactory = function () {
return dataFactory;
};
//
window.connectApi.q = function () {
return $q;
};
//
window.connectApi.launchInterfaceWithData = function (interfaceIdOrKey, payload, params) {
$rootScope.launchInterfaceWithData(interfaceIdOrKey, payload, params);
};
//
window.connectApi.showWidgetDialog = function (title, widgetId, data, addClass, onClose) {
return $rootScope.showWidgetDialog(title, widgetId, data, addClass, onClose);
};
//
window.connectApi.openTaskByWorkItem = function (workItemId, callbackFn) {
$rootScope.openTaskByWorkItem(workItemId, callbackFn);
};
//
window.connectApi.getWorkItemInfo = function (workItemId) {
return dataFactory.getWorkItemInfo(workItemId);
};
//