You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2018-03-12 22:46:50

renato
Guest
Registered: 2018-03-12
Posts: 2

[ENG] How to add Ticket via Plugin?

Hello guys,

How do I create a ticket via plugin?
I'm trying to create a plugin to automatize ticket creation via asynschronous messaging.
I've been searching for this on the documentation, but no luck yet.

Thanks in advance!

Offline

#2 2018-03-12 23:23:20

btry
Guest
Registered: 2015-10-01
Posts: 212

Re: [ENG] How to add Ticket via Plugin?

Hi

To create a ticket via a plugin, create an instance of a Ticket object,  then call  the method add()

$ticket = new Ticket();
$ticket->add([
  'name' => 'my name',
  'description' => 'some text',
  // add other properties here, depending on your needs
]

A ticket is a  rather complex itemtype. Read the method Ticket::prepareInputForAdd()  to get more information about the expected keys you may set in the array passed ti the add() method.

You may have a look into the plugin Formcreator. Its job is actually to create tickets from forms designed by an administrator. If you check this plugin, read the file inc/targetticket.class.php metod save().

Last edited by btry (2018-03-12 23:23:43)


Always run an upgrade task on a testing instance before running it on production ! Always backup before any upgrade task !

Flyve MDM: https://github.com/flyve-mdm/glpi-plugin
Formcreator: https://github.com/pluginsGLPI/formcreator

Offline

#3 2018-03-14 18:39:25

renato
Guest
Registered: 2018-03-12
Posts: 2

Re: [ENG] How to add Ticket via Plugin?

Thanks!

It helped me a lot!

Offline

Board footer

Powered by FluxBB