Alister West

home is where your code is ...

Perl - Request Tracker (RT) - rt-crontool extensions

Update Custom Field based on a Custom Field due date

A client was using a custom-field for the due-date and priority. Then they wanted to escalate on CF based on the Other. I did this with a custom Condition "RT::Condition::BeforeCFDate":http://alisterwest.com/files/RT-Condition-BeforeCFDate.pm and custom Action "RT::Action::UpdateCF":http://alisterwest.com/files/RT-Action-UpdateCF.pm which are designed to be used with rt-crontool In retrospect it would have been faster to just write a seperate script :/, or use --search RT::Search::FromSQL

/path/to/rt-crontool \
     --search    RT::Search::ActiveTicketsInQueue  --search-arg general \
     --condition RT::Condition::BeforeCFDate       --condition-arg 50:7 \
     --action    RT::Action::UpdateCF              --action-arg 11:High \
     --verbose

Update rt-crontool and RT::Date to sensible defaults.

#
# run rt-crontool as SystemUser
#
diff --git a/rt/bin/rt-crontool b/rt/bin/rt-crontool
@@ -114,7 +114,8 @@
-my $CurrentUser = GetCurrentUser();
+#my $CurrentUser = GetCurrentUser();
+my $CurrentUser = RT->SystemUser;

#
# Extend RT::Date to handle simple dates. eg. '2010-02-01'
#
diff --git a/rt/lib/RT/Date.pm b/rt/lib/RT/Date.pm
@@ -174,7 +174,7 @@ sub Set {
-            || ( $args{'Value'} =~ /^(?:(\d{4})-)?(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/ )
+            || ( $args{'Value'} =~ /^(?:(\d{4})-)?(\d\d)-(\d\d)(:? (\d\d):(\d\d):(\d\d))?$/ )
By Alister West