Not your standard "Note" question; email link

9850
50
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

50 Replies
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.

PeterDalrymple
New Contributor III

This is great functionality! Thanks for sharing.

I have one minor issue that maybe someone can help with or that may help others troubleshoot.

It took me a while to figure out why the ${Email_Text_Body} text was not being passed into the email. Turns out that if the hyper link is selected by the user while the cursor is still in the ${Email_Text_Body} field, the email will launch, but no text will be passed into the email. Selecting the hyperlink won't remove the cursor from the ${Email_Text_Body} field. Since ${Email_Text_Body} is the last question in my survey, it requires some explanation to the user or some sort of work around. In this particular case, I'd prefer not to put another question after the ${Email_Text_Body} question.

Let me know if anyone can think of a solution.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Peter,

Unfortunately, this is a limitation of Survey123 - updating calculations will only occur after the cursor leaves the question (otherwise, this would lead to a lot of calculations as they would occur after every key press).

0 Kudos