Skip to main content


 

Symptoms


How to get the current URL as a value in SmartForms
 

Diagnoses


This was logged as a feature request, however there are workaround. See resolution.
 

Resolution

Workaround1
---------------
This workaround will give the form name, but not the full URL
1. Add a parameter to the View
2. On the form, add a rule that when the view initializes - On the input mappings set the View Parameter to tFormName] -> Detail -> Name found in the context browser
3. The View can then use this to determine on which form the user is currently working on.

Workaround2 (using JavaScript)
------------------------------------
1. Add a textbox to the view and give it a name, ex urlTextBox (this textbox can be marked as hidden)
2. Add a data label to the view
3. Set the data label's text to "GetUrl <script>$("$name=urlTextBox]").focus().text(document.URL).val(document.URL).blur()</script>
4. Make sure the Literal flag is selected on the data label - The label can be hidden too
Now you can use the textbox value in the view to determine what the URL is




 

I guess the first workaround will have to do, but it is inconvenient.  I would like to have the current URL as an option in the context browser.

 

An edit is needed in the second workaround.  It does not workin the text, but it will work if you put it in the expression editor.  The problem is that the URL is the GUID URL of the current view (if the controls are in a view).  My use case is to have a footer view with a button to load a feedback form.  I need to know what page I am collecting feedback for.


Did you find a better solution to this?


Reply