logo

NJP

GQL (Glide Query Language) Part 8: Helsinki Studio + Git

Import · Oct 28, 2016 · article

Last time, we built a simple app called GQL Pad that provided user interface for editing and running GQL statements; it also showed results in various formats that we could quickly inspect on the same web page. This time, let's walk through the steps for installing the app on your own instance from GitHub using the Helsinki Studio. If you're already familiar with importing files from GitHub, you may skip most steps below.

FORKING A GITHUB REPOSITORY

If you don't already, you'll need to have an account at GitHub.com. You can sign up for free as long as your repositories are public. GitLab provides private repositories for free and you can use it with the Helsinki Studio. I'll be using GitHub throughout this post.

After logging into GitHub, point your browser to GitHub - snowaid/GQL_v0.1: Glide Query Language initial version from GQL blog where I saved a copy of GQL v0.1 in its own repository. Towards the top right corner, click on "Fork" as shown in the screenshot below:

image

This makes a copy of the repository in your own account, which should take only several seconds. After it's done, you'll be back in your account and see a screen similar to below. Towards top left, make sure you see {your username}/GQL_v0.1 and "forked from snowaid/GQL_v0.1" below it.

image

Then click on the green "Clone or download" button and copy the URL as shown below (we'll paste it shortly below):

image

HELSINKI STUDIO

Now, let's open ServiceNow and navigate to System Applications > Studio and click on "OPEN STUDIO" as shown below:

image

In the next screen, click on "Import from Source Control":

image

Then paste the URL coped from above into the "URL" field and fill in "User name" and "Password": Next, click "Import" (NOTE: although the dialog box says "The account credentials you supply must have read access to the remote repository", you must provide credentials with read/write access or you'll get an error):

image

After several seconds, you'll see a success message like below:

image

Click on the blue "Select Application" button and then click on "gql" as shown below:

image

You'll then be taken to the "Welcome to Studio" page with the "gql" application loaded in the Application Explorer to the left:

image

Now you can modify the application files to your liking in the Studio and stash or commit back to GitHub using the "Source Control" menu.

RUNNING GQL PAD

Once the GQL app is loaded onto your instance, you can run GQL Pad by navigating to GQL > GQL Pad as shown below:

image

OPEN SOURCE COLLABORATION

The GQL app is open source code licensed under a very permissive MIT license and you're welcome to make contributions. While the app you just installed above will be frozen in GitHub in the GQL_v0.1 repository (to ensure it stays in sync with what's been mentioned in this blog series), the working copy of the app is maintained in the separate GQL repository. If you'd like to make contributions, please fork this repository.

LIMITATIONS AND POTENTIAL ENHANCEMENTS

This has been an attempt at demonstrating a proof of concept and we've successfully shown what we set out to accomplish: build a web service that takes SQL-like statements and returns result sets. Along the way, we created the GQL class as a Script Include, which can be called from any server-side scripts. We then built a processor to handle web requests and responses. To interactively demonstrate this, we built a UI Page app called GQL Pad. Everything was kept simple, with very little error handling. The app will work OK for positive cases, but may not perform gracefully when errors are encountered.

Here are some limitations and potential enhancements:

  1. GQL syntax checking: add to UI and GQL class.
  2. GQL syntax highlighting: add to GQL Pad.
  3. Error checking and handling: check for invalid syntax / column / table / encoded query.
  4. Security: may need to use GlideRecordSecure() instead of GlideRecord() to enforce ACL.
  5. Add ability to run SELECT *.
  6. Add calculated fields.
  7. Add aggregate functions: COUNT(), MAX(), MEAN(), etc.
  8. Add UNION: return result sets from multiple SELECT statements as one.
  9. Add JOIN.
  10. Add NEST: allow nesting of result sets from reference tables or related lists.
  11. Add SAMPLE: return random rows based on statistical sampling.
  12. Add XML output format using XMLHelper (can't use in scoped app); alternative might be to use libraries like x2js.

This concludes this series for now. I'll continue to update the GQL repository as I receive your open-source contributions and add enhancements. I may also post follow-up articles if any progress is worth sharing. Thanks for staying with me throughout the series!

Please feel free to connect, follow, post feedback / questions / comments, share, like, bookmark, endorse.

John Chun, PhD PMP [image
View original source

https://www.servicenow.com/community/developer-blog/gql-glide-query-language-part-8-helsinki-studio-git/ba-p/2282354