Since adding the Geolocation control into Nintex Forms, I've been getting a lot of questions around other geo-coding information and how to incorporate it into a business process. This post is actually about a particular process where we use Nintex Workflow, but incorporating a Nintex Form into this would really help things out and make this process very interesting.
The User Defined Action (UDA) in this post, will take a known place or address (preferably, use an address), and it will give you the Latitude and Longitude. This is actually part of a bigger process which I will talk about in a future blog post.
In order to get the Latitude and Longitude, I chose to talk to the Google Geolocation API. Therefore, you need to go to the Google API site and apply for an app api token. Once you have that, make sure you enable it to use the Geolocation API. Then, create a Nintex Workflow Constant and store that token, so that you can use in your workflows without having to type it in each time.
The UDA take 3 parameters:
1. Location Address (input) - this is a location, like an airport name or an address. Preferably an address.
2. Latitude (output)
3. Longitude (output)
The UDA itself is actually quite small. It's made up of 2 actions. The Web Request action, that make a call to the Google Geolocation API, and the Query XML action, that takes the XML response from Google and pulls out the Latitude and Longitude to store in the output Parameters.
The Web Request action is actually quite simple also. The url is made up of
In this case, the Location Address is our input parameter. You can use something like SEATAC, Salt Lake Airport or an actual address. I'd recommend using a complete address if you can, because you're more likely get a result back.
The GoogleApiKey, is the key you would have received from Google, or should appear in your Google API console when you log in. I put this into a Nintex Workflow constant, because I can reuse it later, and I can also set permissions on who I would like to allow to use this.
Also, make sure you set it to perform a GET and store the result in a text variable. This variable will contain a bunch of XML.
NOTE: I would highly recommend you also capture some of the fields, http status and also configure the Error Handling, to make this more robust.
The other action we have is the Query XML action. This action is performing two XPath queries to pull out the Latitude and Longitude.
Latitude - //geometry/location/lat
IMPORTANT : Google has a limit on how many requests your API token can be user for per minute. If you are planning on using more than what is allowed, look for a Work API token (there is probably a fee for that).
Remember, you won't be able to just import this UDA, publish it and use it. It does require the Google API Token, so you'll need to get that first and either put it into the Web Request action, or store it in a Nintex Workflow Constant and use that.
I've attached the UDA to this post. In order to try it out, you will need to download it, then go to Manage User Defined Actions, click on Create and then in the workflow designer page, click on Import and import this in.
Don't have Nintex Workflow and want to try it? Download the trial here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.