There are three built-in actions in Stonefield Query: Email, which launches your email program with an email address filled in; Web site, which navigates your browser to a specific URL; and Report, which runs the specified report.
You can also define custom actions by creating a Link Action script in the Configuration Utility. If you turn on the Link action setting for a script, Stonefield Query automatically includes the description contained in the Description setting in an Action drop-down list in the Link page of the Field Properties dialog.
As an example you may have a Stonefield Query project that reports on a Real Estate database. It would be very useful to add a Link Action where the user can click on a Property ID and have their web browser automatically open to Google Maps with a map of that Property displayed. Below is an example of how to do this but first there are a few rules that Link Action scripts must follow:
Here is a quick example:
lparameters tcFieldName, tuValue
* do whatever is necessary
To open a specific address in Google Maps all we need is the base Google Maps URL (http://maps.google.com/maps?&hl=en&q=) then we can concatenate our Address, City, State, Zip and Country fields to it. Google Maps is very forgiving so the order that you add the fields to the URL is not relevant and it is pretty good at finding the address even if some fields are missing.
To create a Google Maps Link Action: make a new script, check off the "Link action" option and fill in the Description text box with something like: Google Maps
Then, copy and paste the skeleton code below. The only section of code that you will need to alter is the TABLE.FIELDNAME value that gets returned in the discovery call and the function that looks up your specific Address, City, State, Zip and Country fields (here it is called GetLocationforGMaps).
* Google Maps Link Action Script
lparameters tcFieldName, tuValue
local lcURL, lnSelect, lcLocation
* Declare the ShellExecute function so that we can use it to open the
* users browser to our specified URL
DECLARE INTEGER ShellExecute ;
IN SHELL32.DLL ;
* Return the field that will appear in the Action Parameter drop down
* when we Link on this field
* Change this to return your correct TABLE.FIELDNAME
* Save the current work area so we can restore it later
lnSelect = select()
* tuValue will contain the PROPERTYID that the user clicked on
* We need to use that to lookup the Address, City, State, Zip
* and Country fields
* The GetLocationforGMaps() function will be specific to your project
lcLocation = GetLocationforGMaps(tuValue)
* Our lcLocation variable now contains the concatenated Address, City
* State, Zip and Country fields separated by spaces
if not empty(lcLocation)
* Append the location info to the base Google Maps URL
lcURL = 'http://maps.google.com/maps?&hl=en&q=' + lcLocation
* Pass the completed URL to ShellExecute
* ShelleExecute Parameter list: http://support.microsoft.com/kb/238245
ShellExecute(0, 'Open', lcURL, 0, 0, 5)
* Restore the Original Work Area
There is no limit to what you can accomplish with a Link Action script. You could even have your script communicate with another running program and perform a certain action when a user clicks on a field.
For example, in Stonefield Query for Goldmine we have a Link Action where you can make Goldmine itself automatically move to a certain Contact when you click that Contact Name in the Stonefield Query Report Preview window. This is very useful while doing database cleanup.