You are viewing limited content. For full access, please sign in.

Question

Question

URLs in completed forms

asked on December 12, 2020

I have a URL made using custom html field type. It is using a variable from the form. It seems that once the form is complete, the variable I use is no longer is present in the URL. Is that expected behavior?

 

Thanks

0 0

Answer

SELECTED ANSWER
replied on December 14, 2020

So the reason it doesn't work when viewing the completed instance is that most fields are replaced by static div elements in completed instances.

There are some exceptions like radio buttons and checkboxes, but something like a single line, dropdown, textarea, etc. is replaced by a div in that view.

As a result, your code is probably looking for an input and won't find one so it has no value to append to the URL.

What you need is code that can determine whether the view is interactive (input) or read-only (div) and adapt accordingly.

As an example, on the "live" form you may use $('.className input').val() but on the read-only view you'd need something like $('.className div[type="text"]').html()

Even if you're using the ID selectors,

$('#Field1').val() for "live"

$('#Field1').html() for "read-only"

I can't seem to find any of my old code to provide an example, but basically you just make your code dynamic and check which "type" it is before deciding which way to pull the value.

1 0

Replies

replied on December 13, 2020 Show version history

Hi Chris,

Is there any field rule hiding the variable used in custom html field and ignoring its value?

0 0
replied on December 14, 2020

Yes there is. The jQuery can pull the value for the URL, but the field rule hides it? Is that expected behavior? If so, I am guessing I should use a "display: none" rather then use field rules to hide the field? Would that activate the URL? 

 

Thanks for the response

0 0
replied on December 14, 2020

FYI, I removed the 'hide' from Field Rules and it did not resolve the issue. 

0 0
replied on December 14, 2020

Changes to custom HTML elements are not saved when a form is submitted. What JavaScript are you using, and at what point in the process are you seeing the incorrect link? Are you talking about another user task after the submission, or when you view the completed instance?

0 0
replied on December 14, 2020

Thanks Jason

What JavaScript are you using, and at what point in the process are you seeing the incorrect link? just an append html and adding the URL to the <a> element. It does not work once the form is completed. 

Are you talking about another user task after the submission, or when you view the completed instance? When I view the completed instance.

Thanks!

0 0
SELECTED ANSWER
replied on December 14, 2020

So the reason it doesn't work when viewing the completed instance is that most fields are replaced by static div elements in completed instances.

There are some exceptions like radio buttons and checkboxes, but something like a single line, dropdown, textarea, etc. is replaced by a div in that view.

As a result, your code is probably looking for an input and won't find one so it has no value to append to the URL.

What you need is code that can determine whether the view is interactive (input) or read-only (div) and adapt accordingly.

As an example, on the "live" form you may use $('.className input').val() but on the read-only view you'd need something like $('.className div[type="text"]').html()

Even if you're using the ID selectors,

$('#Field1').val() for "live"

$('#Field1').html() for "read-only"

I can't seem to find any of my old code to provide an example, but basically you just make your code dynamic and check which "type" it is before deciding which way to pull the value.

1 0
replied on December 14, 2020

This is excellent, thanks! Any suggestions on making the determination that the form is read-only (completed)? I can build the code, I  am just wondering what is the fastest way to tell if it is completed or not. Thanks again! 

0 0
replied on December 14, 2020

I was trying to find my old code to see exactly how I did it, but no luck. I don't think I looked at the page itself because that can be tricky.

Instead, when assigning the value I just had it choose the "source" based on which element it actually found on the page.

For example, if $('.className input') is null/undefined, then check for the div. There's a lot of ways to do that; it just depends on your exact approach.

0 0
replied on December 14, 2020

ah, ok. got it. Thank you sir!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.