Haaron Gonzalez Rotating Header Image

Nintex Live

How to read values from query string in a Nintex Live Form

I remember when a friend that was very good at writing technical articles and blog posts told me that he didn’t had the time to do it when I asked why he doesn’t blog anymore. That’s exactly what happened to me in the last couple of months or so. I apologize in advance.

Today, I want to share how you can read query string parameters using JavaScript and pass them into a Nintex Live Form controls.

Set the Client ID JavaScript variable name for your text box controls you want to set with the query string values

  • Select your text box control, right click settings
  • Expand the Advanced section
  • Provide a Client ID JavaScript variable name

Set the Client ID

 

Modify the Custom JavaScript i the form Settings

  • Click the Settings ribbon button
  • Expand custom JavaScript section
  • Create a JavaScript function to read and return query string properties ( I borrowed the function from here)

[code language=”css”]

var getQueryString = function ( field, url ) {
var href = url ? url : window.location.href;
var reg = new RegExp( ‘[?&]’ + field + ‘=([^&#]*)’, ‘i’ );
var string = reg.exec(href);
return string ? string[1] : null;
};

[/code]

  • Invoke the function to get the query string values passing the name of the parameter and use the NWF$ to set the values in the right text box. kmsid is my query string parameter

[code language=”css”]

var surveyId= getQueryString(‘kmsid’);

NWF$(document).ready(function() {
NWF$(‘#’+TitleControl).val(surveyId);
});
[/code]

Custom JavaScript

Now you need to make sure your Nintex Live form URL includes the Query String parameter we are referring in the code. In my case I created a Nintex Workflow that will send an email and in the email body a hyperlink to the Nintex Live form is included. I modified the hyperlink to have my query string parameter kmsid, just make sure you don’t use the default URL provided by Nintex Live, use the resulting URL of your Nintex Live form to construct the entire URL with the additional query string.