Hi there, I've been looking at various posts collecting field values to summary boxes and they're terrifically helpful, but I'm trying to combine a few different things and getting stuck, so some more guidance would be excellent!
Here is a simplified view of what I'm doing (I'll be adding more questions, check/radio ranges, and text fields down the line). This is also super unstyled, just looking to nail function before I get into making it pretty.
The custom calculation script reads as follows so far:
event.value="To make the process as smooth as possible, I've put together a " + this.getField("QuestionNum").value + "-question survey that should take around " + this.getField("QuestionTime").value + " to complete." +"/n" +"/n" + "What was (or wasn't!) happening in your "
The "/n" isn't forcing a line break (I tried to keep it inside the sentence quotation marks at first and it returned the same result). The initial sentence and few fields are being pulled in correctly.
After I nail this part, I'm going to need to look at that block of 3 checkboxes and check if each box is chosen (you can select more than one), and output the corresponding text. Again, a thing I think I could figure out if I JUST needed this part in the summay, but combining it with the other stuff is proving tricky.
The final group of pink boxes is a radio selection, again needing to show the question someone selected to include in the script.
Thank you in advance for helping me work through this! I think once I get the basic concept of how to include multiple kinds of info to return (static sentences + fields, yes/no check boxes + fields, radio boxes + fields) in a single summary box, I will be off to the races, but all of the examples I've seen appear to be largely dealing with a single type of data. The end goal is to let the user build the feedback script in the earlier part of the document and then copy/paste out the text from the summary field to email or another survey tool.
Use "\n", not "/n"...
OPE, correct, that forced the line breaks!
Any ideas on how to add the additional questions? Now that I'm past that hurdle, I'll keep trying stuff on my own, but I wasn't sure if I would need to structure it differently to pull in different event types.
So you want to add some text based on the value of a check-box or radio-button? If so, you would need to structure your string as a variable. Something like this:
var s = "Enter fixed text here with some field values";
if (this.getField("Checkbox1").valueAsString!="Off") s+="\nText for Checkbox 1";
if (this.getField("Checkbox2").valueAsString!="Off") s+="\nText for Checkbox 2";
if (this.getField("Radio1").valueAsString=="Option1") s+="\nText for Radio 1, Option 1";
if (this.getField("Radio1").valueAsString=="Option2") s+="\nText for Radio 1, Option 2";
if (this.getField("Radio1").valueAsString=="Option3") s+="\nText for Radio 1, Option 3"; // etc.
s+="\nAdd some more fixed text at the end.";
event.value = s;
This is BRILLIANT and very very close! It displays the fixed text correctly and adds/subtracts the questions as I check boxes or change which radio box is selected. My final hurdle is getting additional field values into the checkbox or radio box display text. Here's what I tried to do with my first checkbox that has a fillable field in it:
if (this.getField("transform1").valueAsString!="Off") s+="\nWhat does a typical " + this.getField("OfferTimePeriod").value + "look like now?";
If you can help me crack this last bit, I believe I will have all the building blocks I need to put together the entire survey builder! Incredibly grateful for your assistance!
Sorry, I don't understand what the issue is... The code you posted seems fine to me.
Oh, man, I tested it without filling in the field I was expecting to show up! It absolutely works, I clearly need more caffeine!
Thank you tremendously for your speedy replies and patience! This forum is such a friendly and useful place to learn. Have a great rest of your day!
No worries, and you're welcome!
If you want to make sure the text is not added when the text field is empty you can use this code:
if (this.getField("transform1").valueAsString!="Off" && this.getField("OfferTimePeriod").valueAsString!="")
s+="\nWhat does a typical " + this.getField("OfferTimePeriod").value + " look like now?";