Hi there
I was looking at the documentation over on
I’m thinking on creating a condition (without rt-crontool) in /opt/rt4/lib/RT/Condition. Which would run a script using it’s id every X mins, is this possible ?
Hi there
I was looking at the documentation over on
I’m thinking on creating a condition (without rt-crontool) in /opt/rt4/lib/RT/Condition. Which would run a script using it’s id every X mins, is this possible ?
Why not use rt-crontool? That’s what its made for! It should be easy to create a custom condition ( Put it in local/lib/RT/Condition/ ) and provide some action to be performed if the condition is true
Thanks for the feedback
So i was playing around with this for a while. My thought is, to create a custom Condition which always returns true in order to do an action.
The action I am trying to do is to run a custom script in RT.
Starting with the Condition
package RT::Condition::RunCustomScriptCondition;
use strict;
use warnings;
use base 'RT::Condition';
sub IsApplicable {
my $self = shift;
return 1; # So always returns true
}
1; # So always returns true
With the Action, I simply wish to run a custom script via ID
package RT::Action::RunCustomScriptAction;
use strict;
use warnings;
use base 'RT::Action';
sub Prepare {
my $self = shift;
return 1;
}
sub Commit {
my $self = shift;
# run custom script
return 1;
}
1;
Hi again
I am using RT 4.4.0 and i can’t seem to find the ‘Action’ & ‘Condition’ section, to create a global action & condition. Was this implemented in 4.4.0?
Thank you for any feedback
Are you performing this action via rt-crontool or wanting to create a new scrip in RT?
I am using RT 4.4.0 and i can’t seem to find the ‘Action’ & ‘Condition’ section, to create a global action & condition. Was this implemented in 4.4.0?
Off the top of my head I believe it is a relatively new feature, maybe added in 4.4.4.
The idea was to create a custom condition and action and make rt-crontool run every x mins.
The way I was going about is it to then attach the custom condition and action to the custom script (in RT) and then make rt-crontool, 1. search for the queue, 2. custom condition, 3. custom action
So without a input of a global action & condition inserted in the RT web interface, this will all fall apart
Now I could also just use rt-crontool to run the custom scripts, i just need to find a way to run a Custom Script ID inside the custom action .pm .
also, the earliest documentation on these global action and condition web interface pages are RT 4.4.2
No but it is available as a plugin on CPAN:
RT::Extension::AdminConditionsAndActions
You don’t want to create a new scrip for rt-crontool, instead you can just point to the new conditions and actions you created:
rt-crontool \
--search RT::Search::FromSQL --search-arg 'Queue="General"' \
--condition RT::Condition::RunCustomScriptCondition \
--action RT::Action::RunCustomScriptAction
When I applied this to the RT_Config.pm,
Plugin(RT::Extension::AdminConditionsAndActions');
followed with
rm -rf /opt/rt4/var/mason_data/obj
i ended up getting an ’ Internal Server Error’. Good thing it wasn’t on the live system.
So for the RunCustomScriptAction, Can I tell it to run Custom Script (23) for example?, i wouldn’t want to run all the scripts in the queue, im not sure if im explaining myself correctly
For the above example,
Very nice, thank you once again
So with you’re example, I am going to try
Now I realized how silly I was, it should be
so easy at the end
Hi sorry again,
I applied the new Condition & Action. When I run rt-crontool, I keep getting this error to load it up in rt-crontool line 187
Can't locate object method "new" via package "RT::Condition::CustomConidition" (perhaps you forgot to load "RT::Condition::CustomConidition"?) at /opt/rt4/bin/rt-crontool line 187. (/opt/rt4/bin/../lib/RT.pm:390)
I tried to load it up inside rt-crontool and found
if ($condition) { my $condition_obj = $condition->new( TransactionObj => $transaction, TicketObj => $ticket, ScripObj => $void_scrip, TemplateObj => $template_obj, Argument => $condition_arg, CurrentUser => $CurrentUser, );
Where did you place the action and condition files?
package RT::Action::RunCustomScriptAction;
/opt/rt4/lib/RT/Condition/
however to be honest with you, it doesn’t really need a Condition to be run because I just tested it.
But it will be good knowledge to know why this happened, maybe I should put it in a different directory? I heard this would be better for upgrading RT in the future
You can actually make a local version so that your custom stuff won’t be wiped away:
/opt/rt4/local/lib/RT/Condition/