Exemple #1
0
<?php

use BITS\ServiceNow\Api;
$cwd = dirname(__DIR__);
set_include_path($cwd . PATH_SEPARATOR . get_include_path());
require_once 'autoload.php';
$sn_user = '******';
$sn_pass = '******';
$sn_url = 'https://example.service-now.com/';
$snapi = new Api($sn_user, $sn_pass, $sn_url);
$params = array('number' => 'xxxxxxx');
$p = $snapi->factory('problem');
print_r($p->soapFields);
echo "\n";
$result = $p->getRecords($params);
print_r($result);
exit;
function Message($number, $message)
{
    $snapi = new Api($GLOBALS['sn_user'], $GLOBALS['sn_pass'], $GLOBALS['sn_url']);
    $inc = $snapi->factory('ITIL\\Incident');
    $params = array('number' => $number);
    $incident = $inc->getRecords($params);
    if (!isset($incident[0]['sys_id'])) {
        echo "Failed to retrieve incident Number!";
        exit(3);
    }
    $sysid = $incident[0]['sys_id'];
    $assid = $incident[0]['assignment_group'];
    $callid = $incident[0]['caller_id'];
    $location = $incident[0]['location'];
    //EDIT KA SCS Assignment Group, SCS Category and SCS Subcagetory
    $params = array('sys_id' => "{$sysid}", 'comments' => "{$message}", 'description' => 'Aspera API Creation Site', 'location' => "{$location}", 'category' => "Support", 'u_scs_category' => 'Data Transfer', 'u_scs_subcategory' => 'Run Service', 'assignment_group' => "{$assid}", 'caller_id' => "{$callid}");
    try {
        $result = $inc->update($params);
    } catch (Exception $e) {
        echo 'Exception: ' . $e->getMessage() . "\n";
        exit(4);
    }
}