Pre-populating answers with custom token attributes

More
6 years 2 months ago #73431 by tacman1123
tacman1123 created the topic: Pre-populating answers with custom token attributes
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

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago - 6 years 2 months ago #73433 by fransmarcelissen
fransmarcelissen replied the 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: 6 years 2 months ago by fransmarcelissen.
The following user(s) said Thank You: tacman1123

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago #73457 by Mazi
Mazi replied the topic: Pre-populating answers with custom token attributes
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
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago #74186 by tacman1123
tacman1123 replied the topic: Pre-populating answers with custom token attributes
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

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago #74223 by Mazi
Mazi replied the topic: Pre-populating answers with custom token attributes
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
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago #74356 by DenisChenu
DenisChenu replied the topic: Pre-populating answers with custom token attributes
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.
( $("#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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago #84880 by ricardo01
ricardo01 replied the topic: Pre-populating answers with custom token attributes
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!

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago #84881 by Mazi
Mazi replied the topic: Pre-populating answers with custom token attributes

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:
<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
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago #84883 by ricardo01
ricardo01 replied the topic: Pre-populating answers with custom token attributes
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

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago #84886 by Ben_V
Ben_V replied the topic: Pre-populating answers with custom token attributes
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)

Please Log in or Create an account to join the conversation.

More
3 years 6 months ago #113229 by jpperrein
jpperrein replied the topic: Pre-populating answers with custom token attributes

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

Please Log in or Create an account to join the conversation.

More
3 years 6 months ago - 3 years 6 months ago #113274 by tpartner
tpartner replied the topic: Pre-populating answers with custom token attributes
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.
Attachments:
Last Edit: 3 years 6 months ago by tpartner.

Please Log in or Create an account to join the conversation.

More
3 years 6 months ago #113296 by jpperrein
jpperrein replied the topic: Pre-populating answers with custom token attributes
Hi,

Ok, many thanks, indeed, I can choose a default value for text purpose. That works fine.
But what if I want to set the default value to an {TOKEN:ATTRIBUTE_1} to a List (radio) question ? - I do not have any place to add my variable, like the text one.

Any clues ?

Many thanks

Please Log in or Create an account to join the conversation.

More
3 years 6 months ago #113299 by tpartner
tpartner replied the topic: Pre-populating answers with custom token attributes
To set defaults for radio questions you can use the Expression Manager Assignment operator in a following equation type question - manual.limesurvey.org/Expression_Manager..._Assignment_Operator

Be sure to make it conditional on the radio being unanswered. Something like:
{qRADIO = if(qRADIO == "", TOKEN:ATTRIBUTE_1, qRADIO)}


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
3 years 6 months ago #113303 by jpperrein
jpperrein replied the topic: Pre-populating answers with custom token attributes
Re,

Ok, the condition is a good thing, thanks.
But I did test it and it does fill the question text but do not change anything on the answer :

What I have done : (ATTRIBUTE_1 = CAT1)

CODE : categorie
QUESTION: Hello, this is my question ... ?
{Categorie = if(Categorie == "", TOKEN:ATTRIBUTE_1, Categorie)}
HELP :nohelp

And the result is
TEXT of QUESTION : Hello, this is my question ... ?
CAT1

O Catégorie 1 (do have the code CAT1)
O Catégorie 2 (do have the code CAT2)
O Catégorie 3 (do have the code CAT3)

So it does "write" CAT1, but on the text of the question, not changing the value of the choice itself.

Hard to explain, sorry :side: .Do you see the issue ?

Many thanks for your help.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!