π Ύ Application Object β
The Application object represents your running application.
Methods β
π Ό app.getAppPage(appPageId) β
Parameters:
appPageId
: The ID of the app page you want to retrieve.
Description: This function returns the user interface app page object for the specified appPageId
. An app page object can be used to manipulate or interact with the page in the application's UI programmatically.
Example:
var myAppPage = app.getAppPage("AP_Welcome");
π Ό app.getAppPageURL(appPageId, appUid) β
Parameters:
appPageId
: The ID of the app page you want to navigate to.appUid
(optional): The UID of the application. If not provided, it defaults to the current application's UID.
Description: Returns the URL for directly navigating to the specified app page. This is useful when you want to create links within your application that lead to other parts of the app.
Example:
var pageUrl = app.getAppPageURL("AP_Settings");
Note
The appUid
parameter is optional. If you do not supply this parameter, it will automatically use the UID of the current scope's object.
π Ό app.getAppURL() β
Parameters: None.
Description: Retrieves the URL for navigating directly to the application. This URL leads to the "Home Page" defined in the application settings.
Example:
var appUrl = app.getAppURL();
π Ό app.getChartsURL(formId, appUid) β
Parameters:
formId
(optional): The UID of the form whose charts page you want to access.appUid
(optional): The UID of the application.
Description: This function provides the URL to navigate directly to the charts page of a specific form within the application. It's useful for creating direct links to data visualizations.
Example:
var chartsUrl = app.getChartsURL(form.getId(), app.getUID());
Note
All parameters are optional. If you do not provide them, the function will default to the current scope's object.
π Ό app.getCurrentUser() β
Parameters: None.
Description: Returns the identifying name of the currently logged-in user. This is determined by the property defined in the application's configuration and might be something like a user ID, email, or display name. If no user is logged in (i.e., anonymous access), it returns "Anonymous Guest User".
Example:
// Set the value of a single line field to the current user's name
BO.F_SingleLine.setValue(app.getCurrentUser());
Note
This function is particularly useful for personalizing the user experience by displaying the user's name or making decisions based on the user identity.
π Ό app.getCurrentUserEmail() β
Parameters: None.
Description: Retrieves the email address of the currently logged-in user. This function is useful for personalizing user interactions or for use in forms and communications within the application.
Example:
var userEmail = app.getCurrentUserEmail();
π Ό app.getCurrentUserDisplayName() β
Parameters: None.
Description: Returns the full display name of the currently logged-in user. This can be used for greeting users or displaying their names on user profiles or dashboards.
Example:
var userDisplayName = app.getCurrentUserDisplayName();
// Output example: "Eduardo RamΓrez LΓ³pez"
π Ό app.getCurrentUserInfo() β
Parameters: None.
Description: Provides an object containing attributes of the current user, such as their ID, email, display name, and user type. It's beneficial for detailed user management and customization.
Example:
var userInfo = app.getCurrentUserInfo();
// Output example: {id: "pflorez123", email: "Pedro.Flores@example.com", displayName: "Pedro Flores", userType: "owner"}
Note
Not all user attributes may be available in all deployments. Unavailable attributes will return null
.
π Ό app.getCurrentUserRoles β
Parameters: None.
Description: Fetches a comma-separated list of all roles associated with the current user. This is particularly useful for role-based access control and permissions within the application.
Example:
var userRoles = app.getCurrentUserRoles();
// Usage in setting value: item.setValue(userRoles);
π Ό app.getFileBaseURL() β
Parameters: None.
Description: Returns the relative URL to the directory storing all files uploaded at design time, excluding images and CSS files. This URL can be used to access these resources directly.
Example:
var fileBaseUrl = app.getFileBaseURL();
π Ό app.getForm(formID) β
Parameters:
formID
: The ID of the form you want to retrieve.
Description: Retrieves the user interface form object for the specified formID
. It's primarily used for adding dynamic event handlers to forms that are not currently displayed.
Example:
var form = app.getForm('F_Form1');
var service = form.getServiceConfiguration('SC_ServiceConfig0');
service.connectEvent('onCallFinished', function (pSuccess) {
alert('Call finished');
});
Note
If you're retrieving a form not currently shown, the returned object will have limited functionality and is best used for event handling purposes.
π Ό app.getFormLaunchURL(formId, appUid) β
Parameters:
formId
(optional): The UID of the form you want to navigate to.appUid
(optional): The UID of the application containing the form.
Description: This function returns the URL for navigating directly to a specific form within an application. You can use this URL to create links that take users straight to a form, improving the navigation flow within your application.
Example:
var url = app.getFormLaunchURL(); // Navigates to the form in the current scope
var urlWithFormId = app.getFormLaunchURL(form.getId()); // Uses form ID
var urlWithFormAndAppId = app.getFormLaunchURL(form.getId(), app.getUID()); // Specifies both form and application IDs
Note
All parameters are optional. If you do not supply a parameter, it will default to the current scope's object.
π Ό app.getImageBaseURL() β
Parameters: None.
Description: Retrieves the relative URL to the directory where all images uploaded at design time are stored. These images are accessible as anonymous resources, meaning anyone can view them.
Example:
var imageUrl = app.getImageBaseURL();
π Ό app.getLocale() β
Parameters: None.
Description: Returns the current locale code of the application. This code follows the standard set by Tags for the Identification of Languages (RFC 3066), and it's determined by the application settings or the current user's preferences.
Example:
var locale = app.getLocale();
π Ό app.getLocation(callbackFunction, highAccuracy) β
Parameters:
callbackFunction
: A function that is called after the location request is completed. This function receives a Position object if the request was successful; otherwise, it receivesnull
.highAccuracy
: A boolean value indicating whether to request a high-accuracy location from the browser.
Description: This function allows the form designer to obtain the current user's geographical location. The callback function can then use this information to perform actions based on the user's location.
Example:
var highAccuracy = true;
var myCallbackFunction = function (position) {
if (position !== null) {
BO.F_SingleLine1.setValue(position.coords.latitude + ", " + position.coords.longitude);
} else {
alert("Location request failed");
}
};
app.getLocation(myCallbackFunction, highAccuracy);
Note
Refer to the MDN documentation on the Position object for more details on the values accessible through the position
parameter. The highAccuracy
option can significantly impact battery life on mobile devices. Visit PositionOptions for more information.
π Ό app.getProductBaseURL() β
Parameters: None.
Description: Returns the base URL of the Domino Leap server, including the host and context. This can be useful for forming URLs to access application resources.
Example:
var url = app.getProductBaseURL();
π Ό app.getRecordURL(recordUid, formId, appUid) β
Parameters:
recordUid
(optional): The UID of the record to navigate to.formId
(optional): The form ID where the record is located.appUid
(optional): The application UID containing the form and record.
Description: Generates a URL to navigate directly to a specific record within an application. This function can simplify the creation of links to specific data entries.
Example:
var url = app.getRecordURL('d1f6eb71-9483-479c-8d47-dd30bd7e9de9');
Note
All parameters are optional. If not supplied, the function will use the current scope's object.
π Ό app.getSharedData() β
Parameters: None.
Description: Provides access to a JavaScript object that can be used across all custom JavaScript code on the form. This object is ideal for sharing data or reusable functions throughout the application.
Example:
app.getSharedData().titleToShow = 'Welcome Form';
app.getSharedData().addTwoValues = function (v1, v2) {
return v1 + v2;
};
// Use the shared data and function
BO.F_SingleLine.setValue(app.getSharedData().titleToShow);
BO.F_Number.setValue(app.getSharedData().addTwoValues(5, 5));
π Ό app.getStyleBaseURL() β
Parameters: None.
Description: Retrieves the relative URL to the directory where all CSS style files uploaded at design time are stored. These files are accessible as anonymous resources.
Example:
var styleUrl = app.getStyleBaseURL();
π Ό app.getSuppressWarning() β
Description: Retrieves the current setting for suppressing warnings within the application. This is useful for controlling whether certain warning messages are shown to the user.
Example:
var suppressWarning = app.getSuppressWarning();
if (suppressWarning === false) {
app.setSuppressWarning(true);
}
Note
Refer to app.setSuppressWarning
documentation for more details on how to suppress warnings.
π Ό app.getUID() β
Description: Returns the unique identifier (UID) of the application, which can be used for creating links to other forms or resources within the same application.
Example:
page.F_StaticWebLink.setLinkValue(BO.F_ServerURL.getValue() + '/apps/secure/1/app/' + app.getUID() + '/launch/index.html?form=F_Form2');
π Ό app.getUrlParameter(parm) β
Description: Fetches the value of a specific URL parameter. This can be used for debugging or to alter the application's behavior based on parameters passed in the URL.
Example:
var param = app.getUrlParameter('debug');
if (param === 'true') {
alert('Shown only when debug param is present');
}
π Ό app.getUrlParameters() β
Description: Returns an object containing all URL parameters. This allows for easy access to any parameter passed through the URL.
Example:
var params = app.getUrlParameters();
if (params.CustomWarning) {
alert(params.CustomWarning);
}
π Ό app.getViewDataURL(appUid) β
Description: Provides the URL to navigate directly to the View Data page of the application. This can be particularly useful for creating links that allow users to view application data with just one click.
Example:
var url = app.getViewDataURL();
var urlWithAppUid = app.getViewDataURL(app.getUID());
Note
The appUid
parameter is optional. If not supplied, it defaults to the current application's UID.
π Ό app.isCurrentUserInRole(roleName) β
Description: Determines whether the currently logged-in user is a member of a specific role within the application.
Example:
item.setValue(app.isCurrentUserInRole("Manager"));
Note
This function does not validate the existence of the role named roleName
; it simply returns false
if the role does not exist.
π Ό app.isSingleFormView() β
Description: Checks if the current form is displayed by itself in the browser or within the context of viewing responses.
Example:
var isSingleView = app.isSingleFormView();
π Ό app.openApp(appUid, newTab) β
Description: Opens the homepage of a specified application. You can choose to open it in a new browser tab or in the current tab.
Example:
app.openApp('d1f6eb71-9483-479c-8d47-dd30bd7e9de9');
app.openApp('d1f6eb71-9483-479c-8d47-dd30bd7e9de9', true);
app.openApp(app.getUID(), false);
Note
If newTab
is true
, the application opens in a new tab. The appUid
is optional; if not supplied, the current application is used.
π Ό app.openAppPage(appPageId, appUid, newTab) β
Parameters:
appPageId
: The ID of the app page to open.appUid
(optional): The UID of the application. If omitted, the current application's UID is used.newTab
(optional): A boolean indicating whether to open the page in a new tab. Defaults to true if not specified.
Description: Opens a specific app page within an application. This function allows users to navigate between different parts of an application seamlessly.
Example:
app.openAppPage('AP_Page1'); // Opens in a new tab by default
app.openAppPage('AP_Page1', true); // Explicitly opens in a new tab
app.openAppPage('AP_Page1', false); // Opens in the current tab
π Ό app.openForm(formId, appUid, newTab) β
Parameters:
formId
: The ID of the form to open.appUid
(optional): The UID of the application containing the form. If not provided, the current application is assumed.newTab
(optional): A boolean that determines whether the form should open in a new browser tab. The default is true.
Description: Enables users to directly open a form within an application. This is particularly useful for applications with multiple forms, enhancing user navigation and experience.
Example:
app.openForm('F_Form1'); // Opens in a new tab by default
app.openForm('F_Form1', true); // Explicitly opens in a new tab
app.openForm('F_Form1', false); // Opens in the current tab
π Ό app.openRecord(recordUid, formId, appUid, newTab) β
Parameters:
recordUid
: The UID of the record to open.formId
(optional): The ID of the form containing the record. If omitted, the current form is assumed.appUid
(optional): The UID of the application. Defaults to the current application if not specified.newTab
(optional): Whether to open the record in a new tab. Defaults to true.
Description: Facilitates direct access to a specific record within a form. This function enhances data navigation and accessibility within applications.
Example:
app.openRecord('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
app.openRecord('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy', true);
app.openRecord('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy', 'zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz', false);
π Ό app.setSuppressWarning(pSuppress) β
Parameters:
pSuppress
: A boolean indicating whether to suppress warning messages.
Description: Controls the display of warning messages that typically appear when attempting to navigate away from a page. This can enhance user experience by eliminating unnecessary interruptions.
Example:
app.setSuppressWarning(true); // Suppresses warnings
π Ό app.showMessage(title, message, type, subtitle) β
Parameters:
title
: The text to display in the dialog title bar.message
: The main text message to display.type
(optional): Specifies the message type ("info"
,"success"
,"warn"
, or"error"
) and controls the icon displayed.subtitle
(optional): A heading text for the message.
Description: Allows the use of a built-in dialog to display messages to the end-user. This function is versatile, supporting various message types for different contexts.
Example:
app.showMessage(
"Error found in data",
"The booking date cannot be after the event.",
"error",
"Please change the booking or event date, then re-submit."
);
Note
Using app.showMessage
is an effective way to communicate information, errors, or success messages directly to users, improving the interactive experience of your application.
Objects available in the app event context β
π Ύ Application object (GUI type) β
- Variable:
app
- Description: Contains functions for accessing global general information
- Example:
app.getCurrentUser();
Example:
var userEmail = app.getCurrentUserEmail();
Events β
π ΄ onStart β
Event Name: onStart
Description: Called once when the browser is first loaded with your application. You can access the formβs interface model for attaching programmatic events. However, nothing else on the form is modified because the forms have not been displayed to the user, nor have they had any data attached.
Example:
- Create a global function for later use:
app.getSharedData().messageBox = function (message) {
alert("Warning: " + message);
};
- Register a function to be called that shows a section when a Service finishes:
var form = app.getForm('F_Form1');
var serviceConfig = form.getServiceConfiguration('SC_ServiceConfig0');
serviceConfig.connectEvent('onCallFinished', function (success) {
form.getPage('P_Page1').F_Section1.setVisible(true);
});