Disallow 'resolve' unless a CF is set?

We need to reject ‘resolve’ actions unless a certain
custom field is set to a value.

Is there a known solution for this, or should I start
hacking?

Because we only require the CF on resolve and at no other time I hacked the update page when status = resolved.

I have seen others put scrips in place that set the status back to open but this didn’t work for us, as we didn’t want the ticket to appear to be resolved (submitted), we wanted to remain on the same page with the typical feedback.

Would be really nice if there was a way to add logic like that to the CF.

Good luck, and let me know if you need additional info on how I did this.

Jeff Stark
Sr Saas Engineer
Moxie Software
(919)622-0418
jstark@moxiesoft.com
Www.Moxiesoft.com
CONNECT PEOPLE. SHARE KNOWLEDGE. DELIVER RESULTS.-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Jeff Blaine
Sent: Wednesday, January 05, 2011 2:03 PM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Disallow ‘resolve’ unless a CF is set?

We need to reject ‘resolve’ actions unless a certain custom field is set to a value.

Is there a known solution for this, or should I start hacking?

Jeff,

Actually, yes, please do provide details if you would.

One would also need to make mods to Modify.html as well, no?

As far as I can tell Update.html called for the “Resolve” link
but there are other ways to resolve a ticket.

Jeff BlaineOn 1/5/2011 4:33 PM, Jeff Stark wrote:

Because we only require the CF on resolve and at no other time I hacked the update page when status = resolved.

I have seen others put scrips in place that set the status back to open but this didn’t work for us, as we didn’t want the ticket to appear to be resolved (submitted), we wanted to remain on the same page with the typical feedback.

Would be really nice if there was a way to add logic like that to the CF.

Good luck, and let me know if you need additional info on how I did this.

Jeff Stark
Sr Saas Engineer
Moxie Software
(919)622-0418
jstark@moxiesoft.com
Www.Moxiesoft.com
CONNECT PEOPLE. SHARE KNOWLEDGE. DELIVER RESULTS.

-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Jeff Blaine
Sent: Wednesday, January 05, 2011 2:03 PM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Disallow ‘resolve’ unless a CF is set?

We need to reject ‘resolve’ actions unless a certain custom field is set to a value.

Is there a known solution for this, or should I start hacking?

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>

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? :slight_smile:

copies locally to implement later

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? :slight_smile:

copies locally to implement later

-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-
bounces@lists.bestpractical.com] On Behalf Of Jeff Blaine
Sent: Wednesday, 12 January 2011 4:39 AM
To: rt-users@lists.bestpractical.com
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>