Dynamic HTML links (to other surveys)

722
3
11-04-2022 05:16 AM
amcnicol
New Contributor II

I have a collection of different forms, offering questions for different vehicle types. If a user doesn't know their vehicle classification, the idea is to use a 'kick-off' survey, in which they enter their [vehicle_reg], and are provided with a link which takes them to the appropriate survey. For ease of use, I'd also like to pre-populate the selected [vehicle_reg] in the new form.

I'm able to do this using the following link structure: <a href='https://survey123.arcgis.app?ItemID=?xxxxxxxxxxxxxxxxxxx&field:vehicle_reg=0000000'>Survey for 0000000</a>. When I have a static link, everything works fine.

My issue however, comes when I want to make this link dynamic. No matter how I format the HTML, whenever I try to pass through the entered [vehicle_reg] into the HTML of the link, it doesn't work. If I concatenate the parts of the link together within the form, the link won't show, takes you to the wrong place, or doesn't pass through the [vehicle_reg]. I think it's something to do with the formatting of the link (the apostrophes or speech marks), so I've tried numerous variations of these, but to no avail.

I've also tried pulling the requested HTML link from an xlsx file using [pulldata], which again, works fine if it's pulling a static link, but not if it's pulling the result of a formula calculation.

Any ideas/advice would be appreciated

0 Kudos
3 Replies
IsmaelChivite
Esri Notable Contributor

Try building the HTML tag in a calculate and then referencing the calculated value in the label.

Attaching example.

amcnicol
New Contributor II

Hi IsmaelChivite

Thanks for your suggestion, but when I run your code, I run into a very similar issue:

Dynamic link.jpg

The issue definitely seems linked to calling in the answers/variables. Whenever I replace them with a static string (in quotes), the link seems to format correctly, without an error. Unfortunately, I do require the link to be dynamic.

0 Kudos
amcnicol
New Contributor II

I found the solution here: https://community.esri.com/t5/arcgis-survey123-questions/survey123-calculated-custom-url-hyperlink-t...

Basically, you use single quotes/apostrophes (') to define the CONCAT text, and speech marks (") to define the link itself:

concat('<a href="', ${survey_link} ,'&field:vehicle_reg=',${vehicle_reg},'">Survey for: ', ${vehicle_reg},'</a>')

 

I had been doing the opposite:

concat("<a href='", ${survey_link} ,"&field:vehicle_reg=",${vehicle_reg},"'>Survey for: ", ${vehicle_reg},"</a>")

0 Kudos