Others
NAVIGATIONS:
openWindowXXX(args)
where XXX is the window identifier (CON08) - open the specified window
openWindowXXX(args, settings)
same of previous method with one more param "settings" to give the windows additional settings. Possible settings parameters:
asMainWindow: boolean value to open the window as the first window in the window stack. It is like to open a window from main menu; (Since 5.2.3 version)
anchoredToPanel and anchoredToAttribute: Display the modal window in a popup window anchored to the bottom-left corner of the anchor view. If there is not enough room on screen to show the popup in its entirety, this method tries to find a parent scroll view to scroll. If no parent scroll view can be scrolled, the bottom-left corner of the popup is pinned at the top left corner of the anchor view. Works only with modal window. (Since 6.0.1 version)
You can use "this" string to open the popup window anchored to the view that triggered the event. (Only works with button's events. Since 6.0.2 version)
anchoredGravity: only works on Android, preferred window anchor position, available values are: TOP,BOTTOM,LEFT,RIGHT or a combination of them separated by a pipe. Ex: BOTTOM|RIGHT anchor the window to the bottom-right corner. Default value is BOTTOM|LEFT. (Since 6.0.1 version)
preferredOpenDirection: only works on iOs, preferred window position relative to anchored attribute. Available values are:UP,DOWN,LEFT,RIGHT. (Since 6.0.1 version)
openFirstWindow()
Opens the first window if set, otherwise the about window.
closeWindow()
Close current visible window and move back to the previous one.
closeWindow(callbackFunName)
Close current visible window and after close call the passed function
setWindowTitle(title);
Change the title of the window currently shown. Required arguments:
getWindowId()
Get the current window id.
getPanelId()
Get the current panel id, null if the panel is not available (for example in a window event).
WORKS WITH ACTION:
executeAction(actionId, params)
execute the specified Actionand returns the result. actionId: a String with the id of the action to execute; params: an object with params to use in the action to execute. These params are accessible in the action to execute by vo.xxx or vo['xxx']
Example
executeServerAction(actionId, params)
execute the specified Server Side Action and returns the result.
Example:
asyncFunction(jsCallback, paramArray, timeout)
Call the function passed in jsCallback with params specified in paramArray.
convertToListJson(list)
Convert a javascript list returned by the executeQuery method to a JSON string having format: [{....},{...},...]
Example
convertToListResponseJson(list,length,moreRows)
Convert a javascript list returned by the executeQuery method to a JSON string having format: { moreRows: ..., valueObjectList: [{....},{...},...] }
Example
convertToObjectJson(list,length,moreRows)
Convert a javascript object contained in the list returned by the executeQuery method to a JSON string corresponding to that object.
Example
MENU, LOGIN AND SYNC:
sync(forceFirstSync,generateAll)
start the synchronization task
syncSqlInstruction()
Send to server the sql instractions of data modified. This operation not is a total sync.
changeCredentials(username, password)
replace the current account with the one specified through "saveCredentials" method and use it by now
saveCredentials(username, password)
save the specified username and password in a permanent area
logout()
Logout the current user and show the login form (if login in enable).
Since 5.3.2 version
filterUserRoles(roles)
Enable only the passed roles, if you want filter the menu leaves you have to call also restartApp('N') method.
clearInitialWindow()
remove the start window.
setMenuType(menuType)
change the menu type used by the app
changeUser(value)
change the username associated to the app
setDrawerIcon(path)
Set the icon on the app drawer.
Example:
setDrawerDescriptionRow1(text, color)
Set the text on the first row on the drawer. setDrawerDescriptionRow2(text) and setDrawerDescriptionRow3(text) are the same.
Example:
TOPBAR APPEARANCE
setTopbarRightDescription(description)
If menu provide a description in the topbar, update the description.
6.0.1 version
Supported menu: left menu
setTopbarRightCharacter(charcter, backcolor, forecolor)
If menu provide a user-char icon update it.
6.0.1 version
Supported menu: left menu
setTopbarButton(title, icon, width, actionId, showNotificationBadge)
if the menu allows you to add a persistent button in the topbar, use this method to add it. We recommend using this method after the app's display event. This feature is useful when you want to show a button to manage notifications. The button can have a text, an icon or both.
6.0.1 version
Supported menu: left menu
setTopbarButtonIcon(icon)
Change the icon of the button create with method setTopbarButton.
6.0.1 version
Supported menu: left menu
GENERIC PANEL:
getPanelParameter(name)
Get a parameter value passed to the current panel (trough the window args variable). Required parameters are:
Example
panelScreenshot(panelid);
Generate an image of the panel shown in the app, identified by idPanel and save it in the local file system. The method gets back the absolute path + image name for the just generated screenshot.
Required arguments:
return the absolute path + image name for the just generated screenshot.
QUEUE:
Uses the following methods to add or remove items in a queue, the queue is accessible in all client side JS.
These methods are very useful when working with asynchronous and callback methods.
atomicEnqueue(String queueName, Object object)
Atomically adds an item to the queue, returns the number of items in the queue
Since 6.0.1 version
atomicDequeue(String queueName)
Remove the first item from the queue and return it
Since 6.0.1 version
atomicQueueTop(String queueName)
Return the first element of the queue without removing it
Since 6.0.1 version
atomicQueueClear(String queueName)
Empty the queue.
Since 6.0.1 version
DATE AND TIME:
addDate(timeInMillis,format,amount)
Return an internal string representation of the current date (with "yyyy-MM-dd HH:mm:ss" format) plus an amount which can be specified with different formats, that can be used when creating javascript objects to insert/update and you need to pass a date. Required parameters are:
Example
getCurrentDate();
Return the current date in string with format yyyy-MM-dd. Use the device time zone.
getCurrentDateAndTime();
Return the current date and time in string with format yyyy-MM-dd. Use the device time zone.
getCurrentDateGMT();
Return the current date in string with format yyyy-MM-dd. Use GMT time zone.
Since 5.3.1 version
getCurrentDateAndTimeGMT();
Return the current date and time in string with format yyyy-MM-dd. Use the GMT time zone.
parseDate(dateString, format, inputGMT);
Parse the passed string with the passed format and returns the timestamp.
Since 6.0.1 version
stringifyDate(dateTS, format, outputGMT)
Convert the passed timestamp with the passed string format and return it
Since 6.0.1 version
OTHERS:
logger(logMessage) or log(logMessage)
Log a message in the internal app console, in order to see it in the Log Panel.
Note: There is also the "log" standard javascript method, used to log on the app console, but in this case, the messages will not be visible in the Log Panel.
reloadPreviewPanelXXX(args)
where XXX is the previewidentifier (CON12) - reload the content of thepreview panel
reloadChartPanel(panelId, args)
where panelId is the previewidentifier (CON12) - reload the content of thepreview panel
Note that you won't find the args in the server side VO (since the server call is made through a GET request, hence no request body is present). You can find the arguments as parameters in the reqHeaders.referer.
For simplicity, here is a snippet to copy the parameters in the VO.
reloadMapPanel()
where XXX is the form identifier (CON12) – reload the form content
loadHTMLOnPreviewPanel(XXX, html)
where XXX is the previewidentifier (CON12) - load the htmlin the preview panel
loadURLOnWebView(XXX, url)
load the url passed in a webview
showCardPanel(cardPanelid, panelid)
Switches from a card to another inside a cardPanel. Required parameters are:
openUrl(url)
Open the browser whith url
vibrate(pattern)
Vibrate with a given pattern. Pass in an array of longs that are the durations for which to turn on or off the vibrator in milliseconds. The first value indicates the number of milliseconds for which to keep the vibrator on before turning it off. Subsequent values alternate between durations in milliseconds to turn the vibrator off or to turn the vibrator on.
NOTE: the pattern only works in Android device
Example:
getTranslation(key)
Returns the translated string corresponding to the key.
Example:
formatNumber(number, format)
Returns the text formatted in the given format and use the language of the logged in user.
setWindowButtonSelected(buttonId, selected)
Select the window button with the specified Id.
POSRequestPayments(host, port, keepSocketOpen, requestImport, printOnPOS, successCallback, errorCallback)
Select the window button with the specified Id.
Since 6.0.1 version
btoa(String stringToEncode)
Creates a base-64 encoded ASCII string from a binary string.
Since 6.0.1 version
atob(String stringToDecode)
Since 6.0.1 version
Decodes a string of data which has been encoded using base-64 encoding.
encodePassword(password)
Since 6.0.1 version
Encrypt the passed password using PBE algorithm
decodePassword(password)
Since 6.0.1 version
Decrypt the passed password using PBE algorithm