Append textbox values to URL

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
joetel8
Posts: 14
Joined: Tue Jan 24, 2017

24 Jan 2017

Hello,

I am seeking assistance on a task to append a text box value to the URL as the field is being added to the textboxes. Example: Amt=Textbox1.value

url+Amt?=[value of Textbox1]

And this value would have to a keyup function.

Any assistance you can provide is greately appreciated.

Thank you,

Joe

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

25 Jan 2017

Hi,

Here is a sample:

Code: Select all

function buildUrl() {
    var url = 'URL?' + fd.field('TextField').value();
    // do something with the url
}

// on text change
fd.field('TextField').change(buildUrl);

// on init
buildUrl();
Replace TextField with the internal name of the field (you can find it in the field's properties in the designer).

joetel8
Posts: 14
Joined: Tue Jan 24, 2017

25 Jan 2017

Thank you Dmitry,

This helps me get to my next element. I am trying to capture the value of the "Amount" field and place it on the URL param so when I open the child "New item" link, I will get the value from the url param and place it on the child form.

I know how to get the url keyvalue with the "fd.getUrlParam(sourceUrl, 'ParamName')" script, but first I need to place the value in the source URL so I can retrieve it.

Any assistance you can provide me is greatly appreciated.

Thank you,

Joe

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

26 Jan 2017

I see. There is no need to place a parameter into URL to pass it into a child window. If you open a child form in a dialogue, you can retrieve a parent's field value this way:

Code: Select all

window.top.fd.field('FieldName').value()

joetel8
Posts: 14
Joined: Tue Jan 24, 2017

26 Jan 2017

Thank you Dmitry,

I know you said I can use this script

"window.top.fd.field('FieldName').value()"

and it works well if I open from a NON Dialogue window, but if I am coming from an open dialogue I am getting "undefined". Is there another script syntax that I can use to read the fields from an open dialogue.

Almost there,

Joe

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

27 Jan 2017

Do you mean that you open both parent and child forms in dialogues?

joetel8
Posts: 14
Joined: Tue Jan 24, 2017

27 Jan 2017

Yes.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

30 Jan 2017

Not a good practce, but you can find the parent dialogue in the list of iframes of the parent window:

Code: Select all

window.top.frames[2].fd.field('FieldName').value()
Test the code with various indices.

joetel8
Posts: 14
Joined: Tue Jan 24, 2017

30 Jan 2017

Thank you Dmitry for your assistance.

I will not open the parent page in a dialog form. But in order for the form to flow in accordance to our process, is there a way I can redirect the user back to the previous page after submit?

That way I don't have to open up a dialog box to collect the fields I need.

Thank you again.

Joe

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

31 Jan 2017

This is how it works by default. The Source URL parameter contains a URL where a user will be redirected after saving or closing a form.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests