Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Pre-populating answers with custom token attributes

  • tacman1123
  • tacman1123's Avatar Topic Author
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 1 month ago #73431 by tacman1123
I want to confirm the user's name, email address and zip code, data I have. I can add those fields to the tokens table, and then say

Our records show that your email address is {TOKEN:EMAIL}. If this is not correct, add the new email below.

But then it will only work if the survey is taken via a token.

What I really want is to pre-populate the answers based on the token (if the survey is taken that way). Otherwise it'd just be the default, e.g.

Please enter your email:

and then have the answer there.

I was hoping to see a Default Answer in the Advanced Options, with the ability to add {TOKEN:EMAIL} as the default.

Is there another way to do this easily?

Thx,

Tac
The topic has been locked.
  • fransmarcelissen
  • fransmarcelissen's Avatar
  • Offline
  • Premium Member
  • Premium Member
More
12 years 1 month ago - 12 years 1 month ago #73433 by fransmarcelissen
Replied by fransmarcelissen on topic Pre-populating answers with custom token attributes
Hi,
Good news, what you want is exactly what I do in my questionnaires in 1.92rc3. 1.92 has the option of defining defaults for text fields. But the defaults are not in the advanced options, but as a button along the conditions button. As a default you can set {TOKEN:EMAIL}, so the user can keep this or change it if he wants. The default can also be a EM script. Of course the TOKEN does not change.
Frans
Last edit: 12 years 1 month ago by fransmarcelissen.
The following user(s) said Thank You: tacman1123
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
12 years 1 month ago #73457 by Mazi
Frans, is this already documented at our manual? If not, can you please add a note there on how to use token data for default settings!?

Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
  • tacman1123
  • tacman1123's Avatar Topic Author
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 1 month ago #74186 by tacman1123
I love the ability to have defaults based on tokens. Sometimes, especially when demoing and developing the site, I want to offer the ability to take the survey without tokens. Right now, it's throwing an error if the token isn't defined.

Is there a way to check for the existence of a token before using it? For example, if I have a field called "industry" in my token list (ATTRIBUTE_1), but the token table hasn't been initialized yet, I just want it to be blank. So maybe something like

Default: IF isset({TOKEN:ATTRIBUTE_1}) TOKEN:ATTRIBUTE_1 ELSE "";

Is that something that's even possible?

Or is there another approach that would work better? In particular, I want to be able to give a link to someone and say "Please review this survey" and not have it fail if I have default answers that will be populated if it's coming from a token-based survey.

Thx,

Tac
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
12 years 1 month ago #74223 by Mazi
This might be possible when using the Expression Manager at Limesurvey 1.92 but for the current 1.91 version I don't know any such solution.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 1 month ago #74356 by DenisChenu
Hello,

I think you can use:
A token table for invitation, set to no-anonymous.

A token with : newinscription for tokencode, set to 1000000 answer ( or more ;).

And in the survey you can use condition to show:
Your email: please put your mail adress: < input >
OR:
Can you confirm your mail adresse YES/NO
( if no : give an new question with your email )

You can fill to an input with the email for token table.
Code:
( $("#question"+QQ+" input.text").val('{TOKEN:EMAIL}');

Denis :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
11 years 6 months ago #84880 by ricardo01
Denis, I was wondering if you could explain how to achieve what you're saying here:

A token table for invitation, set to no-anonymous. DONE

A token with : newinscription for tokencode, set to 1000000 answer ( or more) How? What is a"newinscription" How can I set it to 1000000? where?

You can fill to an input with the email for token table.
( $("#question"+QQ+" input.text").val('{TOKEN:EMAIL}'); Where do I write this?

Thanks!
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
11 years 6 months ago #84881 by Mazi

ricardo wrote: A token with : newinscription for tokencode, set to 1000000 answer ( or more) How? What is a"newinscription" How can I set it to 1000000? where?

I think Denis was talking about the "uses_left" column at which you can define the number of times a certain token can be used.

ricardo wrote: You can fill to an input with the email for token table.
( $("#question"+QQ+" input.text").val('{TOKEN:EMAIL}'); Where do I write this?

Try adding this code at the source code mode of the editor at the related question:
Code:
<script>
   $(document).ready(function() 
   {
      $("#question"+QQ+" input.text").val('{TOKEN:EMAIL}');
   });
</script>
^- replace "QQ" with your question ID.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
More
11 years 6 months ago #84883 by ricardo01
Thanks, Mazi

My question ID is 4903...and this is the script I'm using...is this correct?

<script>
$(document).ready(function()
{
$("#question"+4903+"input.text").val('{TOKEN:EMAIL}');
});
</script>

it's not prepopulating anything yet
The topic has been locked.
More
11 years 6 months ago #84886 by Ben_V
At first glance (in your last script) a white-space is missing just before "input.text"

Wrong:
$("#question"+4903+"input.text").val('{TOKEN:EMAIL}');


Correct:
$("#question"+4903+" input.text").val('{TOKEN:EMAIL}');


Ben/

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
More
9 years 5 months ago #113229 by jpperrein

fransmarcelissen wrote: Hi,
Good news, what you want is exactly what I do in my questionnaires in 1.92rc3. 1.92 has the option of defining defaults for text fields. But the defaults are not in the advanced options, but as a button along the conditions button. As a default you can set {TOKEN:EMAIL}, so the user can keep this or change it if he wants. The default can also be a EM script. Of course the TOKEN does not change.
Frans


Hi, I canno't make this working. The condition part ask me to create a condition. Must be a trick to use it so a default value based on invitation table can be used.

Any clues, would it be possible to have an example ?

Many thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 5 months ago - 9 years 5 months ago #113274 by tpartner
This has nothing to do with conditions. Frans simply meant that the "Default answers" button is beside the "Set Conditionss" button.




.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 5 months ago by tpartner.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose