Skip to content

Survey Code Examples

nlil edited this page Jul 18, 2012 · 2 revisions

Retrieving Remedy customer satisfaction survey data

There is one method for fetching Remedy customer satisfaction survey data:

  • Search using an arbitrary query (surveyList)

Retrieving survey information based on a query

The surveyList method has the same structure as all of the search methods. These methods have one required field -- the search query -- and two optional fields: a start offset, and a max limit. The offset is simply the index of the starting entry and the max limit will limit the returned list of Ids to the specified number. Search methods return only object Ids, instead of actual objects. To retrieve a list of actual objects, loop through the Ids, call a get method with the object's Id and add the returned object to a new list.

Note: the search method will return different objects depending on how many objects are returned. If there is just one object, the search method returns the object. If the number of objects returned is greater than 1, the object returned will contain all of the entries in a "getListValues" variable. In this case, you must iterate over getListValues to retrieve the object Ids (see below).

Queries

Remedy expects queries to have a very specific format. The overall format is the following:

'[label]' [operator] "[value]"

The label is a predefined keyword in the database (see the list below for expected labels and their value formats).
The value should correspond to the label format (i.e. dates formated correctly, etc.) The operator can be any of the following: =, !=, <, <=, >, >=, LIKE You can concatenate conditions using AND or OR operators between conditions.

A summary of the search terms allowed when searching for workgroups can be found below.

###Searching using a query

<?php

/***************************************************************  
 *  
 * Example: Search Remedy surveys by specified qualification
 *  
 ***************************************************************/

require_once 'Ncstate/Service/Remedy.php';

// create a new Remedy object  
$remedy = new Ncstate_Service_Remedy($user, $pass);

// formulate the query
$qual = "'workgroupname' = \"REMEDY\" AND 'comment' != null";

try {
    $surveyList = $remedy->surveyList($qual, 0, 0);
}
catch (Ncstate_Service_Exception $e) {
    die('An error occurred while getting the workgroup:' . $e->getMessage());
}

$surveys = array();
// check if the return value has any entries  
if (isset($surveyList)) {
    /*  
     * Single entry lists are structured  
     * differently than multiple entry objects. We must  
     * therefore check for multiplicity and handle both  
     * cases.  
     */
    if (count($surveyList->getListValues) > 1) {
        foreach ($surveyList->getListValues as $survey) {
            $surveys[] = $survey;
        }
    } else {
        $surveys[] = $surveyList;
    }
}

print "Query returned " . count($surveys) . " surveys.\n\n";
print "Survey comments:\n";
foreach ($surveys as $survey) {
    print "\n$survey->survey_id *********** $survey->customer_firstname $survey->customer_lastname:\n$survey->survey_comment\n"; 
}
// print_r($surveys);
?>

Search terms for the surveys form

action => action field from the call record - string
agent => agent field from the call record - string
datemodified => date modified field from the call record - date-time
datereported => date reported field from the call record - date-time
dateresolved => date resolved field from the call record - date-time
Email Address => email address field from the call record - string
Call-Id => call id with leading zeros - string
callid => short version - int
impact => impact field from the call record - Individual | Group | Site | Enterprise
origin => origin field from the call record - Phone | FAX | V-Mail | E-Mail | Project | Self | Walk Up | WWW | Lab | IM
owner => owner field from the call record - string
priority => priority field from the call record - Low | Medium | High | Critical | Emergency
problem => problem field from the call record - string
product_name => product name field from the call record - string
solutioncall => solution associated with the call - int
Status2 => status field from the call record - New | Assigned | Owned | Active | Defect | Waiting | Closed | Solved
timespent => timespent field from the call record - int
TimeSpnt => timespent field from the call record (formatted) - string
workgroup => workgroup field from the call record - string
Email Address => email address field from the customer record - string
firstname => firstname field from the customer record - string
lastname => lastname field from the customer record - string
username => username field from the customer record - string
ouc => ouc address from the customer record - string
privacy => username field from the customer record - P | null
q1 => Survey question 1 - string
q2 => Survey question 2 - string
q3 => Survey question 3 - string
q4 => Survey question 4 - string
q5 => Survey question 5 - string
q6 => Survey question 6 - string
Create Date => survey create date - date-time
comment => survey comment - string
email => survey email address - string
followup => survey followup - No | Yes
Survey Number => survey id number - string
phone => survey phone number - string
Q1 => survey question 1 response - Strongly disagree | Disagree | Neither agree nor disagree | Agree | Agree strongly
Q2 => survey question 2 response - Strongly disagree | Disagree | Neither agree nor disagree | Agree | Agree strongly
Q3 => survey question 3 response - Strongly disagree | Disagree | Neither agree nor disagree | Agree | Agree strongly
Q4 => survey question 4 response - Strongly disagree | Disagree | Neither agree nor disagree | Agree | Agree strongly
Q5 => survey question 5 response - Strongly disagree | Disagree | Neither agree nor disagree | Agree | Agree strongly
Q6 => survey question 6 response - Strongly disagree | Disagree | Neither agree nor disagree | Agree | Agree strongly
Status => survey status - Rejected | Valid | Followup Requested | Followup Complete
version => survey version - string
workgroupname => survey workgroup - string