Approvals

My employer has requested that I implement approval functionality in RT,
where a ticket cannot be resolved until other RT users have verified and
approved it. I had planned to implement the requests for approval as
separate tickets upon which the original ticket would depend.

I started looking over 2.1.30, and, lo and behold, I see that work has
already begun in implementing such a system, and it seems to work in the
same way that I had thought.

Since I have some resources to devote to this project, I would like to
coordinate with you to help implement this functionality. I’m new to aegis,
so I’ve a bit of a learning curve to tackle as far as sending and receiving
changesets. If you could give me some idea as to where you’re going with
approvals, and how I can best assist in development, that would be great.

  • mdz

My employer has requested that I implement approval functionality in RT,
where a ticket cannot be resolved until other RT users have verified and
approved it. I had planned to implement the requests for approval as
separate tickets upon which the original ticket would depend.

You may wish to check out the 2.1.30 snapshot release in;
http://www.fsck.com/pub/rt/devel/

Which contains basic hooks and the approval mechanism.

The additional insertdata script below creates the logic used for
approvals and stuff, as part of development toward RT3. Basically,
RT2.1.30 implements a ‘strong dependency’ system in which one
ticket cannot be resolved unless the one it dependents on is.

I’ve been assigned to grok all the approval stuff in the next few
days, so if you run into problem/ideas, feel free to post here and
maybe we can help each other a bit. :slight_smile:

Thanks,
/Autrijus/

#!/usr/bin/perl -w

$Header: /raid/cvsroot/rt/sbin/Attic/insertdata,v 1.1.2.1 2002/01/28 05:27:15 jesse Exp $

RT is © 1996-2002 Jesse Vincent (jesse@bestpractical.com);

use strict;
use vars qw($VERSION $Handle $Nobody $SystemUser $item);

use lib “!!RT_LIB_PATH!!”;

#This drags in RT’s config.pm

We do it in a begin block because RT::Handle needs to know the type to do its

inheritance

BEGIN {
use RT;
RT::LoadConfig();
RT::InitLogging();
}
use Carp;

use RT::User;
use RT::CurrentUser;
use RT::Scrip;
use RT::Template;

#connect to the db
require RT::Handle;
$RT::Handle = RT::Handle->new();
$RT::Handle->Connect();

#Put together a current user object so we can create a User object
my $CurrentUser = new RT::CurrentUser();

#now that we bootstrapped that little bit, we can use the standard RT cli

helpers to do what we need

use RT::Interface::CLI qw(CleanEnv GetCurrentUser GetMessageContent);

#Clean out all the nasties from the environment
CleanEnv();

#Load etc/config.pm and drop privs
RT::LoadConfig();

#Connect to the database and get RT::SystemUser and RT::Nobody loaded
RT::Init;

$CurrentUser->LoadByName(‘RT_System’);

{{{ Queues

my $approvals_queue = RT::Queue->new($CurrentUser);
$approvals_queue->Load("___Approvals");
unless ($approvals_queue->Id){
my ($val, $msg) =$approvals_queue->Create(
Name => ‘___Approvals’,
Description => ‘A system-internal queue for the approvals system’,
);

unless ($val) {
warn $msg ."\n";
}
}

}}}

{{{ Scrips

my @scrips = (

{    # If a ticket in approvals is rejected,
       # reject the original request and attach a reply
       # also, delete all other pending approvals

   Description =>

“If an approval is rejected, reject the original and delete pending approvals”,
Queue => $approvals_queue->Id,
ScripCondition => ‘User Defined’,
ScripAction => ‘User Defined’,
CustomIsApplicableCode => ‘
if ( $self->TransactionObj->Field eq “Status” && $self->TransactionObj->NewValue eq “Rejected” ) {
return 1;
}
else { return undef }
’,

     CustomCommitCode => '
    my $links = $self->TicketObj->DependedOnBy;
    while (my $link = $links->Next) {
    my $obj = $link->BaseObj;
    my $pending_approvals = $obj->DependsOn;
    while (my $dependson = $pending_approvals->Next) {
            my $dep = $dependson->TargetObj;
            if ($dep->QueueObj->IsActiveStatus($dep->Status)) {
                    $dep->SetStatus("deleted");
            }
    }
    $obj->Correspond( Content => loc("Your request was rejected") );
    $obj->SetStatus("rejected");
    }',
   CustomPrepareCode => '1',
   Template => 'AdminComment', },



{  Description =>

“When a ticket has been approved by all approvers,”.
" add correspondence to the original ticket",
Queue => $approvals_queue->Id,
ScripCondition => ‘On Resolve’,
CustomPrepareCode => ‘return(1);’,
CustomCommitCode => ‘
#Find all the tickets that depend on this (that this is approving)
my $links = $self->TicketObj->DependedOnBy;
while ( my $link = $links->Next ) {
# the ticket that depends on this one
my $obj = $link->BaseObj;
next unless ($obj->HasUnresolvedDependencies);
$obj->Correspond( Content => loc(“Your request has been approved.”) );
}
return(1);
’,
ScripAction => ‘User Defined’,
Template => ‘AdminComment’, },
{ Description =>
“When a ticket has been approved by any approver,”.
“add correspondence to the original ticket”,
Queue => $approvals_queue->Id,
ScripCondition => ‘On Resolve’,
ScripAction => ‘User Defined’,
CustomPrepareCode => ‘return(1);’,
CustomCommitCode => '
my $links = $self->TicketObj->DependedOnBy;
while ( my $link = $links->Next ) {
# the ticket that depends on this one
my $obj = $link->BaseObj;
$obj->Correspond( Content => loc(“Your request has been approved by [_1]. Other approvals may still be pending.”,$self->TransactionObj->CreatorObj->Name) );
}
return(1);

   ',
   Template       => 'AdminComment' },
{  Description =>
                    "When an approval ticket is created, notify the owner and adminccs".
                    " of the item awaiting their approval",
   Queue          => $approvals_queue->Id,
   ScripCondition => 'On Create',
   ScripAction => 'Notify AdminCcs',
   Template => 'New Pending Approval'
} );

}}}

{{{ Templates

my @templates = ( {
Name => “New Pending Approval”,
Queue => $approvals_queue->Id,
Description => “Notify Owners and AdminCcs of new items pending their approval”,
Content => "Subject: New item pending your approval

There is a new item pending your approval. I have no idea
what autrijus client wants here.
"

              });

}}}

print “Creating templates…”;

use RT::Template;
for $item (@templates) {
my $new_entry = RT::Template->new($CurrentUser);
my $return = $new_entry->Create(%$item);
print $return. “.”;
}
print “done.\n”;

print “Creating scrips…”;

use RT::Template;
for $item (@scrips) {
my $new_entry = RT::Scrip->new($CurrentUser);
my ($return,$cmsg) = $new_entry->Create(%$item);
print $return. “.”;
unless ($return) {
warn $cmsg;

    use Data::Dumper;
    #print scalar Dumper($item);
}

}
print “done.\n”;

$RT::Handle->Disconnect();

1;

My employer has requested that I implement approval functionality in RT,
where a ticket cannot be resolved until other RT users have verified and
approved it. I had planned to implement the requests for approval as
separate tickets upon which the original ticket would depend.

You may wish to check out the 2.1.30 snapshot release in;
http://www.fsck.com/pub/rt/devel/

Which contains basic hooks and the approval mechanism.

As you could see in my original message, I already saw that this
functionality was beginning to be implemented in 2.1.30.

The additional insertdata script below creates the logic used for
approvals and stuff, as part of development toward RT3. Basically,
RT2.1.30 implements a ‘strong dependency’ system in which one ticket
cannot be resolved unless the one it dependents on is.

Thanks, this is very helpful. I noticed that this restriction did not seem
to exist when experimenting with 2.1.30. What also seemed to be missing was
a way to cause a transaction to fail from a scrip; for instance, to reject
it because other requirements had not been met.

I’ve been assigned to grok all the approval stuff in the next few
days, so if you run into problem/ideas, feel free to post here and
maybe we can help each other a bit. :slight_smile:

Sounds good.

  • mdz

Hi all,
i have a little question…
It is possible to create an approval ticket only if the request’s object match a particular word or string?

thx

Nicola

Hi,
what is the secret of approvals?
I’ve studied the doc, searched in the kWiki page and the rt-user list,
played around with the CreateTicket.pm, but I still don’t get the trick.
How do I set up an approval in the queue General.Approval
if a ticket is created in the queue General?
I can’t figure out where I have to put the parts of code which are in the
example in the appnedix of the documentation.

Thanks in advance
Ritschi =B-)

Lose your dreams and you will lose your mind
Rolling Stones - Ruby Tuesday

Dear All,

Could somebody please describe me (in details if possible) the process of
raising tickets which would need approval? In my case different tickets
might need approval from different people. I lost quite some time to figure
this out but failed miserably.

I’m using RT3.

Thanks,

/Lorand.

Has anyone used the approval functionality? If so , what are some tips on
configuring/using?

Don�t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

Anyone find anything online about approvals?? I need a
Queue call ‘purchase-requests’ to use approvals. They
will be approved by 3 people and when they have
approved it goes to joe; joe has final approval then
the pr person gets it. Any help would be great…
perhaps a good link or anything.

Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

http://wiki.bestpractical.com/index.cgi?ManualApprovals
http://wiki.bestpractical.com/index.cgi?ApprovalCreation

Phanoko wrote:

Anyone find anything online about approvals?? I need a
Queue call ‘purchase-requests’ to use approvals. They
will be approved by 3 people and when they have
approved it goes to joe; joe has final approval then
the pr person gets it. Any help would be great…
perhaps a good link or anything.


Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Be sure to check out the RT Wiki at http://wiki.bestpractical.com

Download a free sample chapter of RT Essentials from O’Reilly Media at http://rtbook.bestpractical.com

WE’RE COMING TO YOUR TOWN SOON - RT Training in Amsterdam, Boston and
San Francisco - Find out more at http://bestpractical.com/services/training.html

Drew Barnes
Applications Analyst
Raymond Walters College
University of Cincinnati

Hi,

I’m trying to set up approvals within RT. Everything is still in testing and this isn’t a live system.

The version of RT is 3.8.8, upgraded from an original install of 3.8.7.

I more or less have things working - tickets are created in a queue and enter a state of “Pending Approval”, another ticket is created in the Approvals queue and people with the appropriate permisions can approve or reject a ticket.

If the ticket is approved it changes it’s state from Pending Approval.

If a ticket is denied, however, the original ticket does not get rejected…

I have done some research and came across a thread where I needed a Scrip of the type “If an approval is rejected, reject the original and delete pending approval” - this Scrip did not exist in my installation so I created one in the Approvals queue:

Condition: On Status Cange
Action: User Defined
Template: Approval Rejected
State: TransactionCreate

However, it still does not work (the original ticket does not get rejected).

My Approval Rejected Template looks like this:

#start

Greetings,

Your ticket has been rejected by { eval { $Approval->OwnerObj->Name } }.

Approver’s notes: { $Notes }
#end

It seems I’m missing something, does anyone have the extra code that needs to go into the template to complete the actions (reject original and delete pending approval).

Thanks

Giles

Confidentiality: The contents of this e-mail and any attachments transmitted with it are intended to be confidential to the intended recipient; and may be privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error.

This message was sent from WHG Trading Limited (registered company number 101439) and/or WHG (International) Limited (registered company number 99191), both of which are registered in Gibraltar whose registered office addresses are: 6/1 Waterport Place, Gibraltar. This e-mail may relate to, or be sent on behalf of, a subsidiary or other affiliated company of WHG Trading Limited and/or WHG (International) Limited.

Unless specifically indicated otherwise, the contents of this e-mail are subject to contract; and are not an official statement, and do not necessarily represent the views, of WHG Trading Limited and/or WHG (International) Limited, any of their subsidiaries or affiliated companies.

Please note that neither WHG Trading Limited nor WHG (International) Limited, nor their subsidiaries and affiliated companies can accept any responsibility for any viruses contained within this e-mail and it is your responsibility to scan any emails and their attachments. WHG Trading Limited and WHG (International) Limited, and their subsidiaries and affiliated companies may monitor e-mail traffic data and also the content of e-mails for effective operation of the e-mail system, or for security, purposes.

This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.

Hi,

I’m trying to set up approvals within RT. Everything is still in testing and this
isn’t a live system.

The version of RT is 3.8.8, upgraded from an original install of 3.8.7.

I more or less have things working - tickets are created in a queue and enter
a state of “Pending Approval”, another ticket is created in the Approvals
queue and people with the appropriate permisions can approve or reject a
ticket.

If the ticket is approved it changes it’s state from Pending Approval.

If a ticket is denied, however, the original ticket does not get rejected…

It turns out that the reason for this was that the Approval queue was renamed from “___Approvals” to “Approvals”, while this inferred to be required by the wiki, it seems to break the rejected chain to the original ticket.

I have created a Ticket Custom Field called “Approval Required” with a list of users who would approve tickets. The idea being that the approver would be set either at ticket creation, or afterwards once the ticket has been reviewed by an operator.

I have a Scrip that calls the Approval create template when the Custom Field is set - how do I set the owner of the approval ticket to the value of a custom field in the template??

Confidentiality: The contents of this e-mail and any attachments transmitted with it are intended to be confidential to the intended recipient; and may be privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error.

This message was sent from WHG Trading Limited (registered company number 101439) and/or WHG (International) Limited (registered company number 99191), both of which are registered in Gibraltar whose registered office addresses are: 6/1 Waterport Place, Gibraltar. This e-mail may relate to, or be sent on behalf of, a subsidiary or other affiliated company of WHG Trading Limited and/or WHG (International) Limited.

Unless specifically indicated otherwise, the contents of this e-mail are subject to contract; and are not an official statement, and do not necessarily represent the views, of WHG Trading Limited and/or WHG (International) Limited, any of their subsidiaries or affiliated companies.

Please note that neither WHG Trading Limited nor WHG (International) Limited, nor their subsidiaries and affiliated companies can accept any responsibility for any viruses contained within this e-mail and it is your responsibility to scan any emails and their attachments. WHG Trading Limited and WHG (International) Limited, and their subsidiaries and affiliated companies may monitor e-mail traffic data and also the content of e-mails for effective operation of the e-mail system, or for security, purposes.

This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.