Firstly, the list to query has to be set up – for this example I created a simple custom list and used the out of the box title column. Image 1 shows the list that was created and used in this example.
Image 1) List containing lookup information
One of the first things that need to be done is to gather the SPHostUrl & SPAppWebUrl parameters from the query string, these will be used later when the executor is called.
In this example, the query is done as soon as the page has finished loading, whilst it may have been possible to directly use jQuery ready this seemed to cause intermittent issues where the query would run before Nintex had finished initializing so instead the NWF RegisterAfterReady functionality was used. Once Nintex has finished loading there is another query to get the SP.RequestExecutor script.
The list query is built up using the standard REST APIs. In this example, the query is selecting the Title field for items where the ID is 2. This is obviously a simple example but can be used as a base. The $expand functionality is supported as well.
The results are returned in JSON format which allows easy navigation through the objects. The example below only expects a single result, but .each was used as an example.
Below shows the output from the page. Now that the information has been retrieved it can be used in a custom validation event.