Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Add a perl script in the questionnaire using User Interface

Hello everyone,
I try to collect through the questionnaire certain ENVs (environment variables), namely the device name (PC name or Tablet name).
I using the SSi Web version 7.0.30.

I need to add computer-name ENV in the questionnaire a perl or javascript code.

I have find a solution to obtain some ENV, accessing from browser a demo.pl file with this script:

use strict;

Now I need to add this perl code in the questionnaire  using "SSI Web CAPI Module" user interface, but I don't know where.

Do you have any idea how I could do this?

PS. Also a javascript example to get ENV  is very useful. :)

asked Oct 17, 2019 by vali_stanescu (120 points)

1 Answer

+1 vote
If you want to store a %ENV value in SSI Web 7, the best option may be to add a free format question to your questionnaire with a hidden variable.  Then you can give the free format HTML like this:

<input name="[% QuestionName() %]_ffvar" id="[% QuestionName() %]_ffvar" type="hidden" value="[% Begin Unverified Perl
    return $ENV{'envvar'};
End Unverified %]"/>

"ffvar" must be replaced with the name of the hidden free format variable.  "envvar" must be replaced with the name of the environment variable to be stored.

There's no way to do this with JavaScript alone as browsers limit what personal information they expose to websites.  The closest option with just JS is the user agent, but that is not a 100% reliable way to measure what device the respondent is using.
answered Oct 17, 2019 by Zachary Platinum Sawtooth Software, Inc. (205,575 points)
Hi  Zachary,
Your solution works.
Thanks for your help.