...
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
Window
Client
void hyperLink(String module, String param)
Launches a Fishbowl module by name, and if provided the param should open the record.
Example
Launch the Customer Module, and open Customer ID 5;
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.
Example
Save a CSV.
Code Block |
---|
var csv = "";
fb_client.saveDataToFile("Save CSV","csv","Excel (CSV)", btoa(csv) ); |