<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=RemoteControlLimeSurvey2</id>
	<title>RemoteControlLimeSurvey2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=RemoteControlLimeSurvey2"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=RemoteControlLimeSurvey2&amp;action=history"/>
	<updated>2026-08-22T20:36:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=RemoteControlLimeSurvey2&amp;diff=3117&amp;oldid=prev</id>
		<title>Admin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=RemoteControlLimeSurvey2&amp;diff=3117&amp;oldid=prev"/>
		<updated>2016-04-06T20:36:15Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Implementing a Survey using LimeSurvey Version 2 with RT 3.8==&lt;br /&gt;
With this article, I would like to help you to implement a survey for every ticket, if desired.&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
1. Add a Custom Field called &amp;quot;CustomerSurveyToken&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2. Setup Limesurvey and activate JSON-RPC (http://manual.limesurvey.org/wiki/RemoteControl_2_API)&lt;br /&gt;
&lt;br /&gt;
3. Change the Global Template &amp;quot;Resolved&amp;quot; as following:&lt;br /&gt;
&lt;br /&gt;
 Subject: Your subject&lt;br /&gt;
 Content-type: text/plain; charset=utf-8&lt;br /&gt;
 &lt;br /&gt;
 Your text...&lt;br /&gt;
 [...]&lt;br /&gt;
 {&lt;br /&gt;
 use strict;&lt;br /&gt;
 use warnings;&lt;br /&gt;
 use JSON::RPC::Client;&lt;br /&gt;
 &amp;#039;&amp;#039;;&amp;#039;&amp;#039;&lt;br /&gt;
 }{&lt;br /&gt;
 my $baseurl = &amp;#039;https://your.server/limesurvey/index.php&amp;#039;;&lt;br /&gt;
 my $apiurl = $baseurl . &amp;#039;/admin/remotecontrol&amp;#039;;&lt;br /&gt;
 my $surveyurl = $baseurl . &amp;#039;/survey/index/sid/%s/token/%s&amp;#039;;&lt;br /&gt;
 &lt;br /&gt;
 my $cf_name = &amp;#039;CustomerSurveyToken&amp;#039;;&lt;br /&gt;
 &lt;br /&gt;
 my $user = &amp;#039;username for limesurvey-api&amp;#039;;&lt;br /&gt;
 my $password = &amp;#039;password for limesurvey-api&amp;#039;;&lt;br /&gt;
 my $survey_id = your survey-id;&lt;br /&gt;
 my $token = $Ticket-&amp;gt;FirstCustomFieldValue($cf_name);&lt;br /&gt;
 &lt;br /&gt;
 my ($toEmailAddr) = $Ticket-&amp;gt;Requestors-&amp;gt;MemberEmailAddresses;&lt;br /&gt;
 &lt;br /&gt;
 my $partData = [&lt;br /&gt;
   { email =&amp;gt; $toEmailAddr },&lt;br /&gt;
 ];&lt;br /&gt;
 &lt;br /&gt;
 if($token eq &amp;#039;&amp;#039; &amp;amp;&amp;amp; $toEmailAddr) {&amp;#039;&amp;#039;&lt;br /&gt;
 &lt;br /&gt;
   my $client = JSON::RPC::Client-&amp;gt;new();&lt;br /&gt;
 &lt;br /&gt;
   $client-&amp;gt;{id} = 1;&lt;br /&gt;
 &lt;br /&gt;
   my $sessionKeyResult = $client-&amp;gt;call($apiurl, {&lt;br /&gt;
     method =&amp;gt; &amp;#039;get_session_key&amp;#039;,&lt;br /&gt;
     params =&amp;gt; [$user, $password]&lt;br /&gt;
   });&lt;br /&gt;
 &lt;br /&gt;
   &lt;br /&gt;
   if($sessionKeyResult &amp;amp;&amp;amp; !$sessionKeyResult-&amp;gt;is_error) {&lt;br /&gt;
     my $sessionKey = $sessionKeyResult-&amp;gt;result;&lt;br /&gt;
 &lt;br /&gt;
     my $participantResult  = $client-&amp;gt;call($apiurl, {&lt;br /&gt;
       method =&amp;gt; &amp;#039;add_participants&amp;#039;,&lt;br /&gt;
       params =&amp;gt; [$sessionKey, $survey_id, $partData]&lt;br /&gt;
     });&lt;br /&gt;
 &lt;br /&gt;
     if($participantResult &amp;amp;&amp;amp; !$participantResult-&amp;gt;is_error) {&lt;br /&gt;
       $token = $participantResult-&amp;gt;result-&amp;gt;[0]-&amp;gt;{&amp;#039;token&amp;#039;};&lt;br /&gt;
 &lt;br /&gt;
       my $cf_obj = RT::CustomField-&amp;gt;new($RT::SystemUser);&lt;br /&gt;
       $cf_obj-&amp;gt;LoadByName( Name =&amp;gt; $cf_name );&lt;br /&gt;
       $Ticket-&amp;gt;AddCustomFieldValue(Field =&amp;gt; $cf_obj, Value =&amp;gt; $token, RecordTransaction =&amp;gt; 0); &lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     $client-&amp;gt;call($apiurl, {&lt;br /&gt;
       method =&amp;gt; &amp;#039;release_session_key&amp;#039;,&lt;br /&gt;
       params =&amp;gt; [$sessionKey]&lt;br /&gt;
     });&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 my $url = &amp;#039;&amp;#039;;&amp;#039;&amp;#039;&lt;br /&gt;
 if($token) {&lt;br /&gt;
   $url = sprintf($surveyurl, $survey_id, $token);&lt;br /&gt;
 }&lt;br /&gt;
 $url;&lt;br /&gt;
 }&lt;br /&gt;
 [...]&lt;br /&gt;
 your footer&lt;br /&gt;
 [...]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>