Vadim Tabakman

***NOTE***

This post is superceded now by Dan Stolls awesome post on a new inline function

http://www.sharepointpub.com/nintex-forms-reading-query-string-values/

There's not much to say about this post.  I had been asked about pulling our Query String values from a Nintex Form.

It's actually not that hard. The following is a little code that you can put into the Custom Javascript section of the form settings.

NWF$(document).ready(function()
{
  var myVars = getQueryStringsIntoHashtable();
  if(typeof myVars['name'] === 'undefined' || myVars['name'] == null)
  {
    // do something if the query string value is not found
  }
  else
    alert(myVars['name']);
});

function getQueryStringsIntoHashtable()
{
  var vars = [], hash;
  var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
  for(var i = 0; i < hashes.length; i++)
  {
    hash = hashes[i].split('=');
    vars.push(hash[0]);
    vars[hash[0]] = hash[1];
  }
  return vars;
} 

In the above example, I'm looking for a name,value pair where the name equals "name". If it finds it, it pops up an alert box with the value.

The getQueryStringsIntoHashtable function reads all the parameters from a Query String, splits them up and builds a hashtable (name,value pair).

So if you have a url like http://mycompany.com?x=1&y=2&name=LasVegas, you'll end up with a hashtable that looks like this :

x = 1

y = 2

name = LasVegas.

To access the values, you use the names.  In my case, the function call result was stored in a variable (myVars).  To access the "name" value, you simply do :

myVars['name'];

Posted by Vadim Tabakman Tuesday, May 14, 2013 5:40:00 PM Categories: Javascript Nintex Forms Nintex Workflow Query String
Copyright Vadim Tabakman
Rate this Content 1 Votes

Comments

Wednesday, May 15, 2013 8:23:00 AM
unknown

re: Nintex Forms - Reading Query String Values

Will this work using Nintex Live ?

Wednesday, May 15, 2013 8:43:49 AM

re: Nintex Forms - Reading Query String Values

The answer is yes and no.  When a form is published to Nintex Live, you'll get a shortened url starting with http://ntx.lv with a special code on the end. 

When following that link, you'll find you are redirected to another url which will look something like http://forms.nintex.com.  Query string values on the ntx.lv url don't get passed to the redirected url.

So if you obtains the forms.nintex.com url and added the query string values to that, then it will work as per this post.

cheers,

Vadim

Tuesday, August 20, 2013 1:10:48 AM

re: Nintex Forms - Reading Query String Values

Hii Vadim, 

Great post, is there a way that I can set the parsed Query string value to a field? :) Thanks.

Tuesday, August 20, 2013 12:50:52 PM

re: Nintex Forms - Reading Query String Values

Hi Praveenteja,

yeah you can do that in JS.  If you store the ID of a control in a JS variable (eg. varTitleID).

In the Javascript, you could do something like this :

NWF$('#' + varTitleID).val('hello world');

Just replace the hello world with your variable that has the Query String value.

cheers,

Vadim

Monday, August 26, 2013 6:44:56 AM

re: Nintex Forms - Reading Query String Values

Hi Vadim, 

Thanks a lot, that worked. Actually my requirement was hiding some fields based on query string. Now i can parse, set the value... How can I hide fields based on value.. in this sequence... On "PageLoad" 

1. Parse

2. setting values

3. Hiding fields based on value (Value which I've already set to one of my fields)

Exact sequence OnLoad ....

Any help would be appreciated.... Thanks.

 

Monday, November 11, 2013 9:51:18 PM
Markoooo

re: Nintex Forms - Reading Query String Values

Thanks for this post! I am pretty new to Nintex, and jquery and all. I manage to get my parameter passed and the alert box pops up, but when I try to set the value of my field, no luck. I am trying NWF$('#mytextbox').val(myVars['name']);

If I get that working, my goal is to use the parameter in a lookup field to preselect a value so i you have any tips they would be appreciated.

Monday, November 11, 2013 9:57:23 PM

re: Nintex Forms - Reading Query String Values

Hey Markoo,

you need to make sure that mytextbox is the ID of the control you're trying to update.

What I recommend, is that you open the text control settings, then expand Advanced and turn on the ability to start the control ID in a Javascript variable.  Then in the provided text box under that, give it a name like varMyTextID.

Then go back to the Javascript and do something like this:

NWF$('#' + varMyTextID).val(myVars['name']);

cheers,

Vadim

Tuesday, November 12, 2013 3:41:45 PM
markooooo

re: Nintex Forms - Reading Query String Values

Thanks, that worked! That was the proof of concept, now I need to apply that to a lookup field rather than a text box, I am guessing I will need to unselect the first value and select the value that gets passed through.

 

Cheers!

Tuesday, November 12, 2013 4:41:48 PM
markoooo

re: Nintex Forms - Reading Query String Values

Nope, just need to pass the ID rather thant the text! Thanks again for this post, helped out a lot!

Wednesday, October 22, 2014 11:27:26 AM
Panagiotis
Gravatar

re: Nintex Forms - Reading Query String Values

I have a single Line of textbox and i store the value to a variable (var_Token),
I want to make a URL like: http://serverURL/Site/List/wiki_page.aspx?Token=var_Token and add this to the nintex forms-settings-redirect Url.

How can i do these 2 things??

Thanks,

Monday, December 14, 2015 3:03:06 AM
Husenmahammad M Momin
Gravatar

re: Nintex Forms - Reading Query String Values

it's wonderful post.

Monday, December 14, 2015 8:09:16 AM

re: Nintex Forms - Reading Query String Values

Thanks Husenmahammad

Tuesday, March 22, 2016 11:42:05 AM

re: Nintex Forms - Reading Query String Values

Hi

I know that this solution will not work for i-pads.  What would be an answer for across platform solution?

I need to know how to pass value from webpage to a nintex form.

Any help would be appreciated,

rach

Tuesday, March 22, 2016 11:46:34 AM

re: Nintex Forms - Reading Query String Values

Hi Rachel,

I'm afraid I've never looked into this.  Can you please post it on http://community.nintex.com as someone else may have an answer.

Vadim

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register

Statistics

  • Entries (277)
  • Comments (1769)

Categories