Can I execute a command in Generic Agent on the set fields?
Moderator: crythias
-
- Znuny newbie
- Posts: 69
- Joined: 29 Apr 2016, 10:23
- Znuny Version: 3.2, 5
- Real Name: Dennis Cua
- Company: N/A
Can I execute a command in Generic Agent on the set fields?
Hi,
We have a custom state for example resolve and we want to record a date - resolve date when the ticket is moved to the resolve state. I can use Generic Agent by using a event driven job right?
I can see that in Ticket Filter and Ticket Action the resolve date is reflected. How can I set this to be the date and time when the ticket state is
first updated to resolve? If the resolve date is a dynamic_field of date or date and time. It has a check box in the Ticket Action with a date and time input, I just want to confirm that this automatically updates to the current date?
What if the resolve date was set as dynamic field text. In the text input box can I enter a linux commade like date or perl date function or the OTRS api? Can I execute a OTRS api in the input box? In case your wondering the previous developer created most of the system and resolve date is a dynamic field text so in the Ticket Action its a input text. There's a lot justification and risk changing an existing system.
I'm fairly new sorry. Also how do launch a command in the Generic Agent? Also I'm still troubleshooting my assembled test vm box. And I am not sure if it does not really work or I have SELinux issues again
We have a custom state for example resolve and we want to record a date - resolve date when the ticket is moved to the resolve state. I can use Generic Agent by using a event driven job right?
I can see that in Ticket Filter and Ticket Action the resolve date is reflected. How can I set this to be the date and time when the ticket state is
first updated to resolve? If the resolve date is a dynamic_field of date or date and time. It has a check box in the Ticket Action with a date and time input, I just want to confirm that this automatically updates to the current date?
What if the resolve date was set as dynamic field text. In the text input box can I enter a linux commade like date or perl date function or the OTRS api? Can I execute a OTRS api in the input box? In case your wondering the previous developer created most of the system and resolve date is a dynamic field text so in the Ticket Action its a input text. There's a lot justification and risk changing an existing system.
I'm fairly new sorry. Also how do launch a command in the Generic Agent? Also I'm still troubleshooting my assembled test vm box. And I am not sure if it does not really work or I have SELinux issues again
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Can I execute a command in Generic Agent on the set fields?
What?
Sorry, this was so much confusing text. From what I gather, you want to create a generic agent job, that sets a dynamic field when a certain state is reached.
That's absolutly possible and shouldn't be hard to achieve.
What do you want with text fields and the API ?
Sorry, this was so much confusing text. From what I gather, you want to create a generic agent job, that sets a dynamic field when a certain state is reached.
That's absolutly possible and shouldn't be hard to achieve.
What do you want with text fields and the API ?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
-
- Znuny newbie
- Posts: 69
- Joined: 29 Apr 2016, 10:23
- Znuny Version: 3.2, 5
- Real Name: Dennis Cua
- Company: N/A
Re: Can I execute a command in Generic Agent on the set fields?
I want to know if I can put in the text field input box something like maybe a linux date command or a otrs date api
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Can I execute a command in Generic Agent on the set fields?
Not as easy as with the internal packages, but yes, probably you can:
https://otrs.github.io/doc/api/otrs/5.0 ... te.pm.html
I'd assume you first have to run a ticketGet, then update the dynamic field hash and run a TicketUpdate.
https://otrs.github.io/doc/api/otrs/5.0 ... te.pm.html
I'd assume you first have to run a ticketGet, then update the dynamic field hash and run a TicketUpdate.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
-
- Znuny newbie
- Posts: 69
- Joined: 29 Apr 2016, 10:23
- Znuny Version: 3.2, 5
- Real Name: Dennis Cua
- Company: N/A
Re: Can I execute a command in Generic Agent on the set fields?
Let me see if I get this straight? Your suggestion is to do this progmagtically am I correct. In a custom ticket run a ticketGet(), update the retrieved hash variable and do a ticketupdate?
Mine was a chance shot curiosity question if in the Generic Agent's Ticket Action section if I can put in a text input a linux command like date or an otrs api that gives the current time.
Sorry for the confusion.
Mine was a chance shot curiosity question if in the Generic Agent's Ticket Action section if I can put in a text input a linux command like date or an otrs api that gives the current time.
Sorry for the confusion.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Can I execute a command in Generic Agent on the set fields?
I'm still a bit confused but it's getting clearer. You want:
1) A custom module in a generic agent
2) that sets the value of a dynamic field to the current time ?
1) A custom module in a generic agent
2) that sets the value of a dynamic field to the current time ?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Can I execute a command in Generic Agent on the set fields?
Heres a minimal working example. You have to create a generic agent to filter according to your needs and enter in the custom module field:
"GAModules::Otterhub_Example"
Then create a file:
~otrs/Custom/GAModules/Otterhub_Example.pm and write into it:
Change the name of the dynamic field (here "400CONDescription") and execute the Generic Agent. Your field should now hold the current time.
"GAModules::Otterhub_Example"
Then create a file:
~otrs/Custom/GAModules/Otterhub_Example.pm and write into it:
Code: Select all
#!/usr/bin/perl
# This module is triggered by a generic agent and will set
# the current time to a dynamic field
package GAModules::Otterhub_Example;
use strict;
use warnings;
use utf8;
use lib '/opt/otrs/';
use lib '/opt/otrs/Kernel/cpan-lib';
use lib '/opt/otrs/Custom';
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my $TimeObject = $Kernel::OM->Get('Kernel::System::Time');
my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');
my $DynamicFieldBackendObject = $Kernel::OM->Get('Kernel::System::DynamicField::Backend');
my $TimeStamp = $TimeObject->CurrentTimestamp();
my $DF_Config = $DynamicFieldObject->DynamicFieldGet(
Name => "400CONDescription",
);
my $Success = $DynamicFieldBackendObject->ValueSet(
DynamicFieldConfig => $DF_Config,
ObjectID => $Param{TicketID},
Value => $TimeStamp,
UserID => 1,
);
}
1;
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: Can I execute a command in Generic Agent on the set fields?
Dear RStraub,
I know this is little bit older post, but I need exactly what you described here. Unfortunately I cannot get it work.
I created a Dynamic Field, then I copied your code (with my dynamic field name) to Custom/Kernel/Modules. I ran afterwards "./bin/otrs.Console.pl Maint::Config::Rebuild" and "... Maint::Cache::Delete" just to be sure that there is nothing in the cache. The otrs Deamon is running.
Then I created a job in the Generic Agent and added into Execute Custom Module the name of my pm file (without any input params). I run the job, I don't get any errors, but the fields are not updated.
Could you maybe please write a step-by-step how to make it running? Maybe the Module was not registered correctly? Or it's not correctly called from the Generic Agent?
I would appreciate it a lot. Thanks.
I know this is little bit older post, but I need exactly what you described here. Unfortunately I cannot get it work.
I created a Dynamic Field, then I copied your code (with my dynamic field name) to Custom/Kernel/Modules. I ran afterwards "./bin/otrs.Console.pl Maint::Config::Rebuild" and "... Maint::Cache::Delete" just to be sure that there is nothing in the cache. The otrs Deamon is running.
Then I created a job in the Generic Agent and added into Execute Custom Module the name of my pm file (without any input params). I run the job, I don't get any errors, but the fields are not updated.
Could you maybe please write a step-by-step how to make it running? Maybe the Module was not registered correctly? Or it's not correctly called from the Generic Agent?
I would appreciate it a lot. Thanks.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Can I execute a command in Generic Agent on the set fields?
Hey there
Please provide:
- The name of your package
- The path to your package
- The entry of the Generic Agent where you call this module
and as bonus, the apache/otrs log whilst you execute the GA.
Please provide:
- The name of your package
- The path to your package
- The entry of the Generic Agent where you call this module
and as bonus, the apache/otrs log whilst you execute the GA.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS