-
Notifications
You must be signed in to change notification settings - Fork 4
Search Code Examples
In the new Remedy API, all methods whose names end in -List are search methods. All search methods have the same structure for calling. The method has 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).
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.
/***************************************************************
*
* Example: Searching for Remedy calls
*
***************************************************************/
require_once 'Ncstate/Service/Remedy.php';
// create a new Remedy object
$remedy = new Ncstate_Service_Remedy($user, $pass);
// The search query
$qualification = "('datereported' >= \"12/21/11 12:01 am\" AND 'datereported' <= \"12/22/11 12:01 am\")";
// The start index
$startRecord = 0;
// The max number of entries returned
$maxLimit = 3;
try {
// Get the list of call Ids
$callList = $remedy->callList($qualification, $startRecord, $maxLimit);
$calls = array();
// check if the return value has any entries
if (isset($callList)) {
/*
* Single entry lists are structured
* differently than multiple entry objects. We must
* therefore check for multiplicity and handle both
* cases.
*/
if (count($callList->getListValues) > 1) {
foreach($callList->getListValues as $call) {
$calls[] = $call;
}
} else {
$calls[] = $callList;
}
}
} catch (Ncstate_Service_Exception $e) {
die("An error occured while searching the database:" . $e->getMessage());
}
print("Calls retrieved: " . $calls);
action => string
agent => string
Assignee Group => string
Call-Id => string
callid => int
CustCall => string
datemodified => date-time
nextcontactdate => date-time
datereported => date-time
dateresolved => date-time
E911_phonenumb => string
emailcc => string
Email To => string
External Call ID => string
FirstContactSeconds => int
FirstContact => string
GUID => string
impact => Individual | Group | Site | Enterprise
initial_workgroup => string
Last-modified-by => string
msg_id => string
On-SiteVisit => Yes | No
origin => Phone | FAX | V-Mail | E-Mail | Project | Self | Walk Up | WWW | Lab | IM
ouc => string
ownercall => int
owner => string
priority => Low | Medium | High | Critical | Emergency
problemtext => string
problem => string
productcall => int
product_name => string
QC-ID => string
Sender Email => string
solutioncall => int
Status => New | Assigned | Owned | Active | Defect | Waiting | Closed | Solved
timespent => int (seconds)
TimeSpnt => string (formatted)
TimeToCloseSeconds => int
TimeToClose => string (formatted)
workgroupcall => int
workgroup => string
action => string
agent => string
Assignee Group => string
Call-Id => string
callid => int
class => string
curr => string
email => string
CustCall => string
lastname => string
datemodified => date-time
nextcontactdate => date-time
datereported => date-time
dateresolved => date-time
dept => string
E911_phonenumb => string
emailcc => string
Email To => string
FirstContactSeconds => int
FirstContact => string
firstname => string
GUID => string
h_addr1 => string
h_addr2 => string
h_city => string
home_phone => string
impact => Individual | Group | Site | Enterprise
initial_workgroup => string
Last-modified-by => string
lastname => string
msg_id => string
On-SiteVisit => Yes | No
origin => Phone | FAX | V-Mail | E-Mail | Project | Self | Walk Up | WWW | Lab | IM
ouc => string
ownercall => int
owner => string
position => string
priority => Low | Medium | High | Critical | Emergency
privacy => character "P" | NULL
problemtext
problem => string
productcall => int
product_name => string
Sender Email => string
solutioncall => int
Status => New | Assigned | Owned | Active | Defect | Waiting | Closed | Solved
timespent => int
TimeSpnt => string
TimeToCloseSeconds => int
TimeToClose => string
w_addr1 => string
w_addr2 => string
w_city => string
work_fax => string
work_phone => string
workgroupcall => int
workgroup => string
Notes:
Date-time formats are expected to adhere to this format:
mm/dd/yy hh:ii am | pm
Field names in BOLD are indexed fields. Using these fields in your searches will improve performance significantly.