The JavaScript API will allow dramatically expand the capabilities of your system. In this help topic, we are going to spend a little time detailing the functionality you can accomplish rather quickly using a little bit of JavaScript. If you've used
Share Data, you've already done a little bit of JavaScript Programming.
Background on JavaScript
There are many
JavaScript Tutorials on the net to help you understand it better. JavaScript is a standard technology and has been in use for many years. We chose to use JavaScript because a lot of developers are familiar with it. Javascript can make your applications more accessible and platform independent.
Examples
Every Qrimp app comes with some features that are built using JavaScript.
Share Data for sharing data and
Field Templates for columns validation are built with Javascript. These validation routines are fairly standard. To try an example, go to Design > Field Templates on the Add New view for many of your tables.
Extensibility Options
In this Help Topic, we are going to concentrate on some of the techniques you can use to pull data out of Qrimp and use it in your custom programming activities. To get the most out of this topic, you should be familiar with the
Query String Parameters first.
To make AJAX programming with Qrimp easier, we are using Matt Kruse's AjaxRequest.js from
http://www.ajaxtoolbox.com/. If you are familiar with JavaScript and would like to use Dojo, Prototype, or some of the other common libraries in your site,
Open a Ticket and we will help you with this.
Retrieving Data with AJAX
Because we are using the
XMLHTTPRequest object the following functions will only get data from local urls within your Qrimp app. Attempting to use them with remote URLs will return a security error.
getUrlString(url) This method will download the url and return the content as a string. You can use this function to retrieve a particular value of a particular field for example. Click the button below to retrieve the name of the help topic indicated by the id you enter into the box:
Here is the JavaScript for the example above, click to copy it into your app:
getContent(url,element,clearcontent,startmsg) We could have stream lined the above example using this method, which will download the url and insert the content into the page element indicated by the element parameter. Try this example:
Clear Content
Here is the JavaScript for the Example, click to copy it into your app:
Special Query String Parameters
_INDICATESUCCESS=true will tell Qrimp to execute a command only returning only the status of the operation. If the message is a success it will return the value of the EXECUTE_SUCCESS variable, which is "Changes applied successfully." If the operation fails, the exception message will be returned.
_RETURNRESULT=true is used for creating new records or operations on individual items. For example, say you want to create a new record in a database table. If you append _RETURNRESULT=true to the URL querystring parameter list, the system will return just the single value response. For an INSERT operation that creates a new record, that result will be an integer number identifying the ID value of the new record.
Using &_RETURNRESULT=true can be very useful for creating parent child relationships. For example, you may want to create an Expense Report, get the ID of that new expense report, then create new expense line items under that Expense Report.
_RECORDCOUNT=true will return only the number of items that would be returned for a particular query string.
Special Pages for Programming
banner.aspx allows you to perform Mash Up operations that grab information from external websites. Use banner.aspx with the following Query String Parameters:
?importimage=imageurl&t=table&column=columnname&id=itemid
This command will retrieve an image from a remote website specified by imageurl and save it into your local Qrimp app. The value for the column specified and corresponding to the particular item indicated by itemid and the table will be set to the url for the local file. This functionality will allow you to ingest remote resources and use them locally within your Qrimp App. The imageurl specified need not be only an image, but could be a text file, html file, etc
?getrgb=imageurl will return the average hexidecimal color of a remote image. This is useful for determining, for example, if there are any storm clouds in a weather radar. If the average hex value is close to black, it's a clear day, if it is closer to red, it is very stormy.
?externalurl=urltodownload&starthtml=starthtmlstring&stophtml=stophtmlstring&t=table&column=columnname&id=itemid
This parameter group will download a remote resource and save the value contained in that resource between the specified start and stop html strings, display it with a link to the original resource, and if the user has rights to update the specified table, save it into the column specified.
This feature is used to create powerful mash ups that persist data from multiple locations around the net. The values saved in these columns can be used in Calculated fields, sorted, and used like any other data entered via the normal routes like HTML forms, etc.
You can use
Square Brackets to use values in your database to build custom urls. Watch the
External Data Sources demo on our Demos Page to get a visual idea of how to do this with Amazon's Online Store.
savedesign.aspxThis page is used to enable drag and drop Field Layouts, but can also be used to update fields in your database for a particular record with a particular value. Here are the query parameters:
savedesign.aspx?ptable=tabletoupdate&id=itemid&f=field&v=value
If the update is successful, the value EXECUTE_SUCCESS will be returned. Otherwise, a failure message will be returned.
Summary
The JavaScript API is a complete set of tools that remove all limits on your application. If you need additional support, please contact Qrimp Support.