There is an issue raised that I should create a dynamic field ticket creator group they specifically want it as a drop down. I am able to oblige. The other requirement was when a ticket is created in the webservice it will be set to a value in the ticket creator group.
The web service is created by my predecessor. It was only in the prod so asked someone to copy the php code so I can put it in where I can atleast been given permission to put in the pre-prod. I tried it, it does work. The webservice is a bit too slow took about 2 or 3 minutes it times out before another screen can show it was successfully but the ticket is created, I am able to just print the ticket number and ticket id. So I can query it and confirm.
I am new to otrs not very very familiar with ACL, generic agent I have created several. I tried both, but when I query the database there is not record of the ticket's ticket creator group to have a value if it is created from the webservice. Is webservice not covered by ACL or GenericAgent?
This is the ACL, I just gave very little filters for testing
I have successfully added dynamic field drop down TicketCreatorGroup in the New Phone Ticket, whenever tickets are created, it is mandatory that TicketCreatorGroup has a value. And it is saved. When I went into sysconfig->Tickets->FrontEnd::Agent::TicketZoom or TicketOverview and add the dynamic field it does not show up. Is there a limit to the number of dynamic field that can be added? I was planning to temporary put it there instead of querying the database.
I am not really sure how well maintained the pre-prod server but the mailer doesn't work. And have been working on fixing it. So it would be a great help if you can all be patient with naive questions from me. I need to atleast quickly narrow things like if I missed something during the dynamic field creation or anything like limit to the number of dynamic field's
Is ticket created from webservice covered by GenericAgent or ACL?
Moderator: crythias
-
- Znuny newbie
- Posts: 69
- Joined: 29 Apr 2016, 10:23
- Znuny Version: 3.2, 5
- Real Name: Dennis Cua
- Company: N/A
Is ticket created from webservice covered by GenericAgent or ACL?
Last edited by OTRSRDNewbie on 26 Jul 2016, 07:18, edited 1 time in total.
-
- Znuny newbie
- Posts: 69
- Joined: 29 Apr 2016, 10:23
- Znuny Version: 3.2, 5
- Real Name: Dennis Cua
- Company: N/A
Re: Is ticket created from webservice covered by GenericAgent or ACL?
This is the code my predecessor created, it was only in the production server and had to ask someone to copy it for me so I can put it in the pre-production server. In case your wondering why am I testing, debugging, resolving in the pre-prod server. The development server is inaccessible even before I got here. I have been asking for the access to it until now nothing.
I have changed some of the values like the ip address, password. Tried it and it does create a ticket only it times out in thanks.php. (Also copied thanks.php into the pre-prod). I tried ACL, GenericAgent just as to have minimal change. If I am going to add a code here to add dynamic field to be set I need to change atleast is TicketCreate right?
I have changed some of the values like the ip address, password. Tried it and it does create a ticket only it times out in thanks.php. (Also copied thanks.php into the pre-prod). I tried ACL, GenericAgent just as to have minimal change. If I am going to add a code here to add dynamic field to be set I need to change atleast is TicketCreate right?
Code: Select all
class TicketCreate {
/**
* The ticket create action is ticketCreate.
*
* @var CONST
*/
CONST TICKET_ACTION = 'ticketCreate';
/**
* The ticket create username for webserivce.
*
* @var CONST
*/
CONST USER_NAME = 'otrsdeveloper';
/**
* The ticket create password for webservice.
*
* @var CONST
*/
CONST PASSWORD = '#############';
/**
* The ticket title.
*
* @var string
*/
public static $ticket_title = NULL;
/**
* The ticket create subject name.
*
* @var string
*/
public static $ticket_subject = NULL;
/**
* The t:icket create description name.
*
* @var string
*/
public static $ticket_description = NULL;
/**
* The ticket create body type.
*
* @var string
*/
public static $body = NULL;
/**
* The ticket create customer user name.
*
* @var CONST
*/
CONST CUSTOMER_USER = 'nagios';
/**
* The ticket create queue id.
*
* @var CONST
*/
CONST QUEUE_ID = 84;
/**
* The ticket create state id.
*
* @var CONST
*/
CONST STATE_ID = 1;
/**
* The ticket create priority id.
*
* @var CONST
*/
CONST PRIORITY_ID = 3;
/**
* The ticket create type id.
*
* @var CONST
*/
CONST TYPE_ID = 2;
/**
* The ticket responsible id.
*
* @var CONST
*/
CONST RESPONSIBLE_ID = 229;
/**
* The ticket SLAID.
*
* @var CONST
*/
CONST SLAID = 9;
/**
* The ticket service id.
*
* @var CONST
*/
CONST SERVICE_ID = 40;
/**
* The ticket create body content type.
*
* @var CONST
*/
CONST CONTENT_TYPE = 'text/html; charset="iso-8859-15"';
/**
* The ticket create webservice URL.
*
* @var CONST
*/
CONST WEBSERVICE_URL = 'https://xxx.xxx.xxx.xxx/otrs/nph-genericinterface.pl/Webservice/WebServices';
/**
* __Construct
*
* @var string $ticket_title, $ticket_subject
*
* @access public
* @return void
*/
function __construct() {
$this->ticket_title = $ticket_title;
$this->ticket_subject = $ticket_subject;
}
/**
* soapClient
*
* @var int $webservice_url
* @access public
* @return soap client
*/
public function soapClient(){
try
{
// make sure it's the same as the namespace in network config of the webservice
$client = new SoapClient(NULL,
array('location' => self::WEBSERVICE_URL,
'uri' => 'Core',
'trace' => true,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED));
}
catch (Exception $e)
{
return $e->getMessage();
}
return $client;
}
/**
* ticketCreateAction
*
* @var int $client,$ticket_id
* @access public
* @return ticket_id
*/
public function ticketCreateAction(){
$host = trim($_REQUEST['host']);
$service_status = trim($_REQUEST['service_status']);
$service_infromation = trim($_REQUEST['service_infromation']);
// Define the status name by int vlaue
if($service_status == 0) $service_status = 'OK';
if($service_status == 1) $service_status = 'WARNING';
if($service_status == 2) $service_status = 'CRITICAL';
if($service_status == 3) $service_status = 'UNKNOWN';
$this->ticket_title = 'NagiosYES4G - '.$service_infromation.' -'.$host;
//$this->ticket_title = 'NagiosYES4G - Test Ticket - Please kindly ignore - OTRS Team';
$this->ticket_subject = $this->ticket_title;
$this->ticket_description = $this->ticketDescriptionTable($host,$service_status,$service_infromation);
// call otrs soap client
$client = $this->soapClient();
$ticket_id = $client->__soapCall(self::TICKET_ACTION, array(
new SoapParam(self::USER_NAME, "UserLogin"),
new SoapParam(self::PASSWORD, "Password"),
new SoapParam(array(
"Title" => $this->ticket_title,
"CustomerUser" => self::CUSTOMER_USER,
"QueueID" => self::QUEUE_ID,
"StateID" => self::STATE_ID,
"PriorityID" => self::PRIORITY_ID,
"TypeID" => self::TYPE_ID,
"ResponsibleID" => self::RESPONSIBLE_ID, // mon.otrs
"SLAID" => self::SLAID, // Sev 3
"ServiceID" => self::SERVICE_ID,
), "Ticket"),
new SoapParam(array(
"Subject" => $this->ticket_subject,
"Body" => $this->ticket_description,
"ContentType" => self::CONTENT_TYPE,
), "Article"),
// Set Value for the Particular DynamicFields
new SoapParam(array("Name" => "Severity", "Value" => 'Severity 3'), "DynamicField") ,
new SoapParam(array("Name" => "Category1", "Value" => 'Server'), "DynamicField") ,
new SoapParam(array("Name" => "subCat", "Value" => 'Others'), "DynamicField") ,
));
return $ticket_id;
}
/**
* ticketDescriptionTable
*
* @var string $host, $service_status, $service_infromation
* $service_duration, $last_check_time, $next_scheduled_check
* $host, $service_status, $service_infromation,
* $last_check_time, $next_scheduled_check
*
* @access public
* @return table
*/
public function ticketDescriptionTable($host,$service_status,$service_infromation){
// Request from Thruk
$service_duration = trim($_REQUEST['service_duration']);
$service_infromation = trim($_REQUEST['service_infromation']);
$last_check_time = trim($_REQUEST['last_check_time']);
$next_scheduled_check = trim($_REQUEST['next_scheduled_check']);
$description = "***** NagiosYES4G Service Monitor XI Alert *****<br>";
$description .= "Status: ".$service_status."<br>";
$description .= "Service : ".$service_infromation." <br>";
$description .= "Host: ".$host."<br>";
$description .= "Service Duration: ".$service_duration."<br>";
$description .= "Last Check: ".$last_check_time."<br>";
$description .= "Next Check: ".$next_scheduled_check."<br>";
return $description;
}
}
// Create object for ticket create
$ticket = new TicketCreate();
// call ticket create action
$ticket_id = $ticket->ticketCreateAction();
if($ticket_id['TicketNumber'] != "")
{
$tn = $ticket_id['TicketNumber'];
$tid = $ticket_id['TicketID'];
header("location:https://xxxxxxx.xxxxxxxx.xxxxxx/nagios/thanks.php?tn=$tn&tid=$tid");
}
?>
-
- Znuny newbie
- Posts: 69
- Joined: 29 Apr 2016, 10:23
- Znuny Version: 3.2, 5
- Real Name: Dennis Cua
- Company: N/A
Re: Is ticket created from webservice covered by GenericAgent or ACL?
Solved it. Sorry people when I arrived here there were so many tickets already and they expect everything done in short period. Suffered. A little blindness/tunnel vision already. The answer was in front of me.