Table of Contents | ||||
---|---|---|---|---|
|
Introduction
Below is a list of methods grouped by the resource they interact with. These methods are available to the page under the fb_client
object that is injected into the browser window. Unfortunately, we are unable to interact with these methods using native objects. So passing complex data is done by serializing objects into JSON strings, and vice-versa.
Methods
Database
String runQuery(String sql)
Executes a SQL string, and returns an array of records as JSON objects. If there is an error, it returns an object. Note: All result properties will be returned in lowercase.
...
Code Block |
---|
var results = fb_client.runQuery("select *, from so limit 10"); |
String runQueryParameters(String sql, String json_parameters);
Executes a SQL string like runQuery, but accepts a single object with parameters serialized as JSON. To define a parameter use :name
syntax, and use all lower case parameter names in SQL and in the JSON object.
...
Code Block |
---|
var params = JSON.stringify({customer_id:5}); var results = fb_client.runQueryParameters("select * from so where customerid = :customer_id", params ); |
API - REST
restApiCall(String method, String path, String body)
Makes an HTTP API call, re-using the Fishbowl Client connection, via the Java networking stack. This is a BETA feature, and is not guaranteed to work correctly or break in the future. You can find REST swagger docs using the Fishbowl Server web port, reference: XXXX.
...
Code Block |
---|
var result = fb_client.restApiCall("GET","/company"); console.log(result); |
API - Legacy
String runImportCSV(String import_type, String csv_data)
Creates and executes a an ImportRequest, given a string of an import_type (Reference: XXX Legacy Fishbowl CSV Import Reference ) and a CSV string. The method returns a JSON object as a string.
...
Code Block |
---|
var csv = ""; var import_type = "ImportCustomFieldData"; var result = fb_client.runImportCSV(import_type, csv); console.log(result); > "" |
String runApiJSON(String request_type, String json_payload)
Executes a legacy API call given a request_type, see reference (XXXXX(Reference: Legacy Fishbowl XML/JSON API Call Types ), and a JSON Payload. The internal Fishbowl Legacy API is XML, and Fishbowl will convert our JSON to XML, and on a completed request will convert XML to JSON.
Take note that there are some bugs with the XML<>JSON conversion, namely if an property is intended to be a list but has a single record/object, it will serialize as an object, and not a list. Reference: TBD.
Examples
TBD
Code Block |
---|
var request = {}; var request_json = JSON.stringify(request); var result_json = fb_client.runApiJSON("XXX",request_json); var result = JSON.parse(result_json); console.log(result); > TBD |
Window
boolean dialogClose()
Closes the current browser window. Warning, the page execution will stop once the browser is closed.
...
Code Block |
---|
var closing = fb_client.dialogClose(); |
void showStatusBar(boolean show)
Hides/Shows the status bar of the browser window, which includes a status label, and a small progress bar.
Examples
Show the status bar.
Code Block |
---|
fb_client.showStatusBar(true); |
Image TBD
Hide the status bar.
Code Block |
---|
fb_client.showStatusBar(false); |
Image TBD
void dialogStatus(String message)
Displays a short message in the status bar, approx. less than 100 characters.
Example
Code Block |
---|
fb_client.dialogStatus("Hello"); |
Image TBD
void pbUpdate(int value)
Controls the Progress Bar component in the status bar. Use whole integers for 0-100, and -1 for indeterminate progress.
Examples
Set progress bar to 100%
Code Block |
---|
fb_client.pbUpdate(100); |
Image TBD
Set progress bar to 50%
Code Block |
---|
fb_client.pbUpdate(50); |
Image TBD
Set progress bar to indeterminate.
Code Block |
---|
fb_client.pbUpdate(-1); |
Image TBD
Client
String getCompanyName()
Returns the company name.
Example
Get the company name
Code Block |
---|
var company_name = fb_client.getCompanyName();
console.log(company_name); |
int getUserId()
Returns an int of the current user id.
...
Code Block |
---|
var user_id = fb_client.getUserId(); console.log(user_id); > 1 |
String getUsername()
Returns a string of the current username.
...
Code Block |
---|
var user_name = fb_client.getUsername(); console.log(user_name); > "admin" |
String getUserEmail()
Returns the current user’s email.
Example
Code Block |
---|
var user_email = fb_client.getUserEmail();
console.log(user_email);
> "admin@example.com" |
boolean savePluginDataByGroup(String group_name, String data_dictionary)
Saves data (JSON or Plain String) to the Fishbowl Plugin data tables (plugindata). The data dictionary is expected to be a JSON object (single level, no hierarchy).
Example
Code Block |
---|
TBD |
String getPluginData(String group_name, String key)
Retrieves a string, given a group_name, and key.
Example
Code Block |
---|
void deletePluginData(String group_name)
Deletes plugin data by the group_name.
Example
Code Block |
---|
String getModuleName()
Returns the current module’s name, from where it was launched. TEST
Example
Code Block |
---|
var module_name = fb_client.getModuleName(); console.log(module_name); > "Sales Order" |
boolean reloadObject()
Reloads/refreshes the current modules object.
...
Code Block |
---|
var refreshed = fb_client.reloadObject(); |
int getObjectId()
If the page is launched from a Module, like Sales Order module, it will return the current Module’s ID, example, the Sales Order ID that is currently displayed. Returns a -1 if the Page is not launched from a Module.
Example
Code Block |
---|
var sales_order_id = fb_client.getObjectId(); // 5 |
void hyperLink(String module, String param)
Launches a Fishbowl module by name, and if provided the param should open the record.
...
Code Block |
---|
fb_client.hyperLink("Customer","5"); |
File
String getResourceFileString(String filename)
Retrieves a file name from the root of the page folder. Warning: We do check for path traversal.
...
Code Block |
---|
var query_sql = fb_client.getResourceFileString("sql/test.sql"); |
String getResourceFileAsBase64(String filename)
Retrieves a file name from the root page of the folder, as a Base64 string of bytes. Warning: We do check for path traversal.
...
Code Block | ||
---|---|---|
| ||
var image_b64 = fb_client.getResourceFileString("images/example.png"); console.log(image_b64); # > ..... |
void saveDataToFile(String title, String extension, String extension_description, String base64_data)
Displays a Java JFileChooser dialog so we can influence, control the window, and file filter in the dialog from JavaScript.
...