cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Glass
Nintex Newbie

GetQueryString for EditForm

Jump to solution

Hello,

I would like to populate a TxtField using a querystring url for EditForm..

as like .../EditForm.aspx?ID=1&TxtField=1. This works fine for NewForm with default textField value "fn-GetQueryString(TxtField)".

any suggestion how can i achieve the same for EditForm ? any Javascript?

Labels: (1)
Tags (2)
0 Kudos
Reply
8 Replies
eiben
Nintex Newbie

Re: GetQueryString for EditForm

Jump to solution

What happens when you use the same function in the edit-form?

0 Kudos
Reply
Glass
Nintex Newbie

Re: GetQueryString for EditForm

Jump to solution

Tryed in edit-form..Field TxtField remains empty. Thanks

0 Kudos
Reply
eiben
Nintex Newbie

Re: GetQueryString for EditForm

Jump to solution

Ah - you used the function in the "default value" setting of the control. Once you saved the item the control does not evaluate a new default value, as the control already has a value.

In this case there will be no way except some little custom javascript.

First you need to store the control-id in a javascript variable. You can do that by:

  1. opening the properties of the control
  2. open the advanced settings 
  3. set "Store Client ID in JavaScript variable" to "yes"
  4. set a value in "Client ID JavaScript variable name" (for e.g. "txtFieldCtl")

Next you'll have to add some custom javascript to the form-settings.

NWF.FormFiller.Events.RegisterAfterReady(function() {
	var urlParams = new URLSearchParams(window.location.search);
	var myParam = urlParams.get('TxtField');
	NWF$("#" + txtFieldCtl).val(myParam);
});

This will grab the query-string 'TxtField' and assign it to the textbox.

You might want to check if your browser support URLSearchParams. Otherwise you have to grab to query string in a different way.

0 Kudos
Reply
Glass
Nintex Newbie

Re: GetQueryString for EditForm

Jump to solution

Hi eiben,

Much appreciated for your neat explaination. i see "URLSearchParams" listed as not supported for my version of IE 11. Tho i tryed with IE.. didnt work.. does works with Chrome. 

what other option you would advice for IE..

0 Kudos
Reply
eiben
Nintex Newbie

Re: GetQueryString for EditForm

Jump to solution

If you're running on-premises you could use this code instead:

NWF.FormFiller.Events.RegisterAfterReady(function() {
	JSRequest.EnsureSetup();
	var myParam = JSRequest.QueryString['TxtField'];
	NWF$("#" + txtFieldCtl).val(myParam);
});
0 Kudos
Reply
Glass
Nintex Newbie

Re: GetQueryString for EditForm

Jump to solution

Hi eiben,

That works.. Thanks..

objective is to hide a panel based on the value populated in dynamic query sting. eg(.../EditForm.aspx?ID=1&TxtField=1)

Rule: (TxtField == '1') -> hide panel doesnt work

Rule: Is Edit Mode && (TxtField == '1') -> doesnt work as well..

i did try with  adding a delay function to run the above RegisterAfterReady function.. to update the value in the TxtField with a delay of 5 sec. still pannel doesnt hide..

any suggestions?

0 Kudos
Reply
eiben
Nintex Newbie

Re: GetQueryString for EditForm

Jump to solution

That's because the event for processing the rules is not being triggered if you change the value of the control via JavaScript. So you either have to move the focus to another control or you have to trigger the event-processing yourself like:

NWF.FormFiller.Events.RegisterAfterReady(function() {
	JSRequest.EnsureSetup();
	var myParam = JSRequest.QueryString['TxtField'];
	var myField = NWF$("#" + txtFieldCtl);
	myField.val(myParam);
	NWF.FormFiller.Functions.ProcessOnChange(myField);
});
Reply
Glass
Nintex Newbie

Re: GetQueryString for EditForm

Jump to solution

That works like a charm`!

Thank you for your patience and support

0 Kudos
Reply