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
Member
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
Moderator
Registered: 2015-10-01
Posts: 588

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)


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

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

renato
Member
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