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?
Solved! Go to Solution.
What happens when you use the same function in the edit-form?
Tryed in edit-form..Field TxtField remains empty. Thanks
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:
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.
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..
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); });
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?
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); });
That works like a charm`!
Thank you for your patience and support