Not your standard "Note" question; email link

15796
52
Jump to solution
05-09-2017 04:14 AM
by Anonymous User
Not applicable

Hello,

I am attempting to use a "Note" question to create a hyperlink to launch an email containing information from my Survey123 form that was built within Survey123 Connect v2.0.35.

I have a set of 6 questions that pertain to project details that I am having our project managers fill out through the Survey123 app. I have a text question that is set to multi-line that contains some text and also pulls in the answers to the 6 questions to create what will be the body text of the email (please see below).

"Hello GIS Department," + "\n"+ "\n"+"This is a request to set up a new GIS application with the following information below:" + "\n"+ "\n" + "Project Number: " + ${ProjectNumber} +"\n" + "Project Name: " + ${ProjectName}+"\n" + "Site Name: " + ${SiteName}+"\n" +  "Company Name: " + ${CompanyName}+"\n" + "ESI Project Lead: " + ${ESI_ProjectLead} +"\n" +  "ESI Field Lead: " + ${ESI_Field_Lead} + "\n" + "\n"+ "Thanks"

Next I have a "Note" question that has a calculation to pull together the hyperlink text that is needed to launch an email and then allow the user to send off the email. That works perfectly (see below).

concat('<a href="mailto:',${Email_Name},'?subject=GIS App Setup&body=',${Email_Body_Text},'">Link to email info</a>')

Next, I want the user to submit the survey form, but this is where things hang up. I receive an error code 1000 "String or binary data would be truncated. The statement has been terminated."

Can anyone provide some insight on what this error means and how to get around the error to allow the survey to be submitted?

Ismael Chivite

James Tedrick

I would greatly appreciate any help or insight.

Thank you in advance,

Mike

52 Replies
by Anonymous User
Not applicable

Chris,

I do not currently have the full answer to your question, but out of curiosity I opened up my Survey123 Connect and then opened a form that uses a custom URL to pass attributes from one form into another form and it worked. When I clicked on the note that creates the custom URL it opened my desktop version of the field app and applied the data transfer into a new form.

It appears as though this is now possible or maybe I just got lucky? It also appears as though the custom URL was not constructed correctly and that is easy to do.

concat('<a href="https://survey123.arcgis.com/share/1f16c2a2e9fb435d8f3c5f4a7f622f?field:Address=${Address}&field:Online_Test=${Online_Test}">Link</a>')

I think this is where things might have gone wrong for your custom URL and the use of the concat(). if you look at these two link very carefully, then you will see that there were some single quotes left out of the function. I made them bold, but they might not be noticeable and they are located in between the text of the hyperlink and your field/question names.

concat('<a href="https://survey123.arcgis.com/share/1f16c2a2e9fb435d8f3c5f4a7f622f?field:Address=',${Address},'&field:Online_Test=',${Online_Test},'">Link</a>')

Give the link above a try and let me know if that works. I appologize for the delay, but these last two weeks have been quite busy for me.

Cheers!

Mike

0 Kudos
by Anonymous User
Not applicable

I can't get it to work - if a field has special characters.

e.g. ', ", &

Any suggestions on how I could fix this?

Thanks so much,

Gee

0 Kudos
by Anonymous User
Not applicable

Gee,

Could you describe what is happening?

I am not a hundred percent sure on this, but I think what may be happening is that the special character is breaking the URL that is generated behind the scenes. I think the correction for this problem would be to find and replace of those characters create the correct URL.

This is a good resource - HTML URL Encoding Reference that I had used in creating this function. If you scroll down a little bit on the page, then you will find a section that is titled "Try it Yourself". If you were to enter in a phrase, then the webpage would open a new webpage and display how that phrase would be URL encoded.

So for instance, an "&" would be encoded using "%26"; an example would be the phrase "Red & Blue" and this results in an encoding of "Red+%26+Blue".

0 Kudos
by Anonymous User
Not applicable

Thanks for the information Mike Bruening‌.

Yes, the special characters seem to break the URL.

I can't seem to apply an encoding or a replace text function ${to_a_field} get around special characters.

But, it's no biggie as the users can still copy the ${email_body_text} directly from the field app to their email client 

STILL love this script a lot.

It has helped me so much in streamlining some of our workflows  

Thanks,

Gee

by Anonymous User
Not applicable

Thanks for the information Mike Bruening‌.

Yes, the special characters seem to break the URL.

And, I can't seem to apply an encoding or a replace text function ${to_a_field} to get around special characters.

But, it's no biggie as the users can copy the ${email_body_text} directly from the field app, into their email client 

Thanks,

Gee

by Anonymous User
Not applicable

Gee,

Would you possibly be able to use some sort of "custom pulldata()JavaScript Function" like within the Early Adopter program to accomplish the find and replace of the characters that are breaking the URL? Just thinking outside the box.

by Anonymous User
Not applicable

Thanks Mike,

Yeah, I was thinking of the same thing 

I'll get onto it - when I have some spare time (and share the script)

by Anonymous User
Not applicable

Spare time...I know what you mean...

0 Kudos
MattVRobinson
Esri Contributor

There's also new functionality integrating Microsoft Flow with Survey123 to automate workflows. One automation task is the ability to send an email when a Survey is submitted and include information from the survey form.

https://community.esri.com/groups/survey123/blog/2018/07/19/automating-workflows-with-survey123-and-... 

0 Kudos
by Anonymous User
Not applicable

Hey Matt,

Thanks for the heads up, but keep in mind that the current MS Flow setup for Survey123 is for "New Survey Submittals" only and not from the Inbox or Sent folders; just yet.Plus, I created this way back before the mention of web hooks...

So, while the webhooks are awesome for one time submittals or unless you getting really fancy within the webhook and using multiple hosted feature services to allow for the generation of the emails after the initial submittal...this method will allow for the creation and sending of emails within any survey form at any time. You should also check out Integromat also; as it can be a fairly powerful webhook utility also.

Survey123 will be the application that changes the way we do work and will continue to push our abilities to above and beyond what they typically are.