Will do.
On 1/11/2011 5:24 PM, Stuart Browne wrote:
I don't suppose you could throw that up onto the wiki so people don't have to
hunt it down through the mailing list archives? :)
*copies locally to implement later*
-----Original Message-----
From: [email protected] [mailto:rt-users-
[email protected]] On Behalf Of Jeff Blaine
Sent: Wednesday, 12 January 2011 4:39 AM
To: [email protected]
Subject: Re: [rt-users] Disallow 'resolve' unless a CF is set?
SUMMARY:
Here's how I did it, based on code from others. Two callbacks
that are very similar in code. The end result is that if a
user tries to resolve a ticket when a certain CF is not set,
that user will get an error message within the RT page
due to the Abort() call. In an ideal world, the user would
see the error message and be provided with the data to correct,
but I couldn't figure out how to get that to work properly
using the callback calls *provided by RT*.
======================================================================
Part 1: "Modify.html/Default" callback (user submitted a form from
The Basics)
<%INIT>
# Modify.html/Default
my $ARGSRef = $ARGS{'ARGSRef'};
# Bail if a resolve operation is not being tried.
my $Status = $$ARGSRef{'Status'};
if ($Status !~ /resolved/) {
return 1;
}
my $ticket = LoadTicket($$ARGSRef{'id'});
my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
my $nam = $CustomField->Name;
my $val = $ticket->FirstCustomFieldValue($nam);
if (($nam =~ /SomeRequiredField/i) and ($val =~ /^\s*$/)) {
Abort("ERROR: SomeRequiredField must be set to allow resolving.
Please use your browser's 'Back' button to correct this issue as
desired.");
}
}
return 1;
</%INIT>
<%ARGS>
</%ARGS>
======================================================================
Part 2: "Update.html/Initial" callback. User clicked "Resolve"
hyperlink on a ticket (upper right).
<%INIT>
my $ARGSRef = $ARGS{'ARGSRef'};
# Bail if a resolve operation is not being tried.
my $DefaultStatus = $$ARGSRef{'DefaultStatus'};
if ($DefaultStatus !~ /resolved/) {
return 1;
}
my $ticket = LoadTicket($$ARGSRef{'id'});
my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
my $nam = $CustomField->Name;
my $val = $ticket->FirstCustomFieldValue($nam);
if (($nam =~ /SomeRequiredField/i) and ($val =~ /^\s*$/)) {
Abort("ERROR: SomeRequiredField must be set to allow resolving.
Please use your browser's 'Back' button to correct this issue as
desired."); }
}
return 1;
</%INIT>
<%ARGS>
</%ARGS>