Running Stonefield Query from another web application

To display the Stonefield Query UI from another web application, simply navigate the browser to the appropriate path. If you want to automatically log the user in, specify "username=username" and "password=password" in the URL, where username and password are the Stonefield Query user name and password, respectively. If you're concerned about passing the user name and password in clear text, do the following:

  • Call the static GenerateUserToken method of the static Stonefield.Library.SecurityFunctions class, passing it the user name and password to log in as. This method returns a security token which is only good on the system it was generated on and only for 20 seconds.

  • Immediately navigate the browser to the appropriate path, specifying "token=tokenstring" in the URL, where tokenstring is the token returned from GenerateUserToken.

To automatically run a report, specify "ReportToRun=reportID" in the URL, where reportID is the ID of the report. You can get the ID by looking in the SFX file for the ID element or by using the ID property of the report object; it's a GUID that'll look something like "e7d51c47-2df0-4a44-b177-642023145557." Here's an example (note that most of token was omitted for brevity):

To run a report and display only the preview window, not the rest of the Stonefield Query UI, use "ReportPreviewDirect/report" in the URL. Here's an example (note that most of token was omitted for brevity):

If you need to pass a value for an ask-at-runtime filter condition, you can add it to the URL as well. The syntax for this is:


where filterID is the ID of the filter condition and values are the values for the condition. You can get the filter ID by looking in the SFX file for the filter condition with the fieldname element set to the desired field and then get the value of the ID element. For example, here's part of an SFX file:


In this case, the filter condition is on the Orders.OrderDate field, so if that's the correct condition, use 56651a75-9202-41e6-bd4d-0302cb3ad6ec (the value of the ID element) as the filter ID.

If you need to specify more than one value, such as for an Is Between or Is One Of condition, separate the values with commas.

For example, to set the value for a condition to the value "Stonefield":

Here's an example with more than one value:

For date values, use YYYY-MM-DD HH:MM:SS. For example:
  &8df41129-86be-4800-9a47-08495d6ec9e8=2014-1-1 00:00:00,2014-12-31 23:59:59

Using the Stonefield Query API

The Samples\SQWeb URL API Example folder has a Visual Studio solution showing how a web application can use the Stonefield Query API. It has a helper class named SQWebConnection that you can instantiate and use directly. It's very simple to use and actually hides the details of how to interact with the API. Currently the helper only has support for adding, updating, and deleting users and roles, but we'll add additional API support in the future.

If you'd rather implement your own HTTP request code, you can use the internals of SQWebConnection as a guide. Note that the project only contains the Model classes for user and role, as well as supporting classes. These are basically copies of the SQWeb project model classes with behavior removed.