Callbacks

Hi,

I’m using RT 4.04.
I want to make a callback on top of the page that if a CF is empty when
I resolve one ticket…
I search in rt-users and I found this one user that do this:

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>

I can’t understand how I can put this in RT , I suppose that the above
code is written for RT 3 and not for RT4 because I don’t find 'Initial’
or ‘Default’.

Any ideas that how I can implement or where exactly I have to put the
above code to make me a callback with a message if there are any CF
empty on resolve?

THANKS!


/ / Daniel Garc�a Mej�a
C E / S / C A Portals i Repositoris
/_/ Centre de Serveis Cient�fics i Acad�mics de Catalunya

Gran Capit�, 2-4 (Edifici Nexus) - 08034 Barcelona
T. (NULL) - F. 93 205 6979 - dgarcia@cesca.cat