OTRS call python function after ticket creation

Moderator: crythias

Post Reply
Markusnoob2
Znuny newbie
Posts: 17
Joined: 27 Feb 2020, 12:34
Znuny Version: OTRS5
Real Name: markus

OTRS call python function after ticket creation

Post by Markusnoob2 »

Hello,

I want to call a python function with command line arguments after a ticket is created.

The command line argument should be the ticket ID.

" /var/test.py -c "ticket_id" "

Is that possible?
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS call python function after ticket creation

Post by jojo »

yes thats possible via the "Execute Ticket Commands" function in the Generic Agent
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
Markusnoob2
Znuny newbie
Posts: 17
Joined: 27 Feb 2020, 12:34
Znuny Version: OTRS5
Real Name: markus

Re: OTRS call python function after ticket creation

Post by Markusnoob2 »

And how would you pass the ticket id?

" /var/test.py -c { ???} "

is it necessary to pass the arguments or are they automaticly set to the end of the command?
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS call python function after ticket creation

Post by jojo »

the function will add two parameters to the command. The first parameter is the TicketID and the 2nd one is the full Ticket number.

You can try with this small shell script:

Code: Select all

#!/bin/bash
echo $1";"$2 >> /tmp/tickets.txt
exit 0
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
Markusnoob2
Znuny newbie
Posts: 17
Joined: 27 Feb 2020, 12:34
Znuny Version: OTRS5
Real Name: markus

Re: OTRS call python function after ticket creation

Post by Markusnoob2 »

Thank you for your help.

But should i specify the path like this:
bash /opt/otrs/scripts/test.sh

or like that:
bash scripts/test.sh
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS call python function after ticket creation

Post by jojo »

full path should be used
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
Markusnoob2
Znuny newbie
Posts: 17
Joined: 27 Feb 2020, 12:34
Znuny Version: OTRS5
Real Name: markus

Re: OTRS call python function after ticket creation

Post by Markusnoob2 »

Okay thank you very much for your help!
Post Reply