- Posts: 19
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Create a relation between custom data and survey data.
- AuPath
- Topic Author
- Offline
- New Member
Less
More
4 years 2 weeks ago #196009
by AuPath
Create a relation between custom data and survey data. was created by AuPath
Hello everyone, i'm a new limesurvey user and was trying to integrate limesurvey with a custom javascript script that tracks the user's mouse movement.
My issue is when i try to associate this custom data with the survey data, specifically a survey record.
When i look into the database i can see that each survey has a series of records with an id, it would be great if i could use this id as a foreign key in my custom data. How can i have access to this id while the user is taking the survey? Is that possible? Does anyone have a better solution?
My issue is when i try to associate this custom data with the survey data, specifically a survey record.
When i look into the database i can see that each survey has a series of records with an id, it would be great if i could use this id as a foreign key in my custom data. How can i have access to this id while the user is taking the survey? Is that possible? Does anyone have a better solution?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
4 years 2 weeks ago #196017
by holch
SavedID gives you the ID that Limesurvey is giving to the current response.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Create a relation between custom data and survey data.
Code:
{SAVEDID}
SavedID gives you the ID that Limesurvey is giving to the current response.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- AuPath
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
4 years 2 weeks ago #196018
by AuPath
Replied by AuPath on topic Create a relation between custom data and survey data.
Thank you, another quick question, under what scope do i have access to {SAVEDID} ? What i'm currently doing is making a custom theme where i added a <script> tag in the question page. When i try to for example console.log({SAVEDID}) it does not print the id, it prints {SAVEDID}. Sorry if it's a stupid question but i'm a total beginner.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
4 years 2 weeks ago #196021
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Create a relation between custom data and survey data.
You should be able to use {SAVEDID} anywhere in your survey to display it.
I have no ID with Javascript, but I have heard that LS only recognizes EM code in JS code if you leave a space before the code. So you could try this.
I probably would write the {SAVEDID} into a equation type question and hide it via CSS (not via the GUI "Always hide this question", because JS can't access it then).
I have no ID with Javascript, but I have heard that LS only recognizes EM code in JS code if you leave a space before the code. So you could try this.
I probably would write the {SAVEDID} into a equation type question and hide it via CSS (not via the GUI "Always hide this question", because JS can't access it then).
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- AuPath
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
4 years 2 weeks ago #196023
by AuPath
Replied by AuPath on topic Create a relation between custom data and survey data.
Do you have a link on how to reference questions with JS?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 2 weeks ago - 4 years 2 weeks ago #196024
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Create a relation between custom data and survey data.
You will need to wrap {SAVEDID} in quotes as it is not a JavaScript variable.Thank you, another quick question, under what scope do i have access to {SAVEDID} ? What i'm currently doing is making a custom theme where i added a <script> tag in the question page. When i try to for example console.log({SAVEDID}) it does not print the id, it prints {SAVEDID}.
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ console.log('{SAVEDID}'); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 2 weeks ago by tpartner.
The following user(s) said Thank You: holch
The topic has been locked.
- AuPath
- Topic Author
- Offline
- New Member
Less
More
- Posts: 19
- Thank you received: 0
4 years 2 weeks ago #196027
by AuPath
Replied by AuPath on topic Create a relation between custom data and survey data.
Thank you for your reply but this does not seem to work, it just prints {SAVEDID}.
Just to be clear i am putting this code in the question.twig page of my custom theme.
I'm doing this because i want this code to be applied to all questions of all surveys that use this theme.
Is this the wrong approach?
Just to be clear i am putting this code in the question.twig page of my custom theme.
I'm doing this because i want this code to be applied to all questions of all surveys that use this theme.
Is this the wrong approach?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 2 weeks ago #196029
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Create a relation between custom data and survey data.
Placeholders are not directly available in TWIG files, you need to define them via the processString() function.
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ console.log('{{ processString('{SAVEDID}') }}'); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.