Get current URL survey

Hello! I'm wondering which code to use if I want to pull the current survey URL into a SingleLine text field.

I want to have a column with the URL of the survey once I export the database to excel, so users can access to the survey without having to find them in their mailbox

Thanks in advance!

Hi Guillermo,

May you please tell which design element where the survey URL is? You mean from text to singe line entry? Please share sample screenshot of use case if applicable.

Thanks,

Jayve

I want to provide access to form's submissions through the excel sheet that can be exported in the "View data" feature to many users

I'm creating a workflow of 5 steps

I want to put a Single Line entry text field in the 2nd stage (Once the 1st stage or Launch stage is completed). In that field, I want to automatically capture the URL of the current form, so I can include this field in the export database and have a column with the direct link to the form

Thanks!

Thanks for providing the use case Guillermo.

If that's the case, you can use two methods:

1. The first method is if your current setting for secureJS is set to false, you can simply put the below sample code in onShow event of Single Line entry:

item.setValue(window.location.href)

2. Otherwise, the second method is you can use the below format to capture current URL form dynamically.

The format of the link is:
<host name>/forms/landing/org/app/<app id>/launch/index.html?form=<form id>

Please apply that format by using the sample code below in onShow event of Single Line entry:

const baseURL = app.getProductBaseURL(); // returns the host and context of the Leap server
const hostName= baseURL.substring(0, baseURL.lastIndexOf("/")); // get host name only
const appID = app.getUID(); // get application ID
const currentForm = form.getId(); // get current form ID

// concatenate all together to capture the URL of the current form
const currentFormURL = hostName + "/forms/landing/org/app/" + appID + "/launch/index.html?form=" + currentForm

item.setValue(currentFormURL);

If you think an answer answered your question, please accept it. It will benefit others having same problem / query.

Hope this helps.

Thanks,

Jayve

The second option worked! Now the field is being filled with the URL automatically

Thanks!

You're welcome.

Hi Javier,

I found out that the URL is not being full copied. The code is missing the specific ID for each form submitted. Below is the picture. I need to pull that too. How do we include it in the code? Thx!

Hello Guillermo,

Sorry for the confusion, the solution I provided before is for launch another form from within your form.

May you please try this one instead?

item.setValue(app.getRecordURL())

As per documentation, it will return the URL for navigating directly to the current record if there is no parameter was set:

https://help.hcl-software.com/leap/9.3/ref_application_object.html

Please note to adjust Single Line Entry's Max char in order to store record url properly.

Hope this helps.

Thank,

Jayve

Once document was saved, the value in the view data of the single line entry is look like this: