[rt-users] RT Approvals

Emmanuel Lacour elacour at easter-eggs.com
Mon Sep 14 06:12:59 EDT 2015


Le 14/09/2015 10:27, Kobus Bensch a écrit :
> Hi
> 
> I have setup approvals following this doc:
> https://www.bestpractical.com/docs/rt/4.2.12/customizing/approvals.html.
> 
> I would like to setup multiple approvers based on a value in a custom
> field. Is this possible and if so can anybody point me in the right
> direction or to a doc that I can read that will help me to achieve this?
> 
>

you'll have to write code yourself ;)

You cannot use groups for this?


Here is sample untested code (that needs more time to think of) to get
users with a user cf corresponding to ticket cf. Just an idea ...

I would create a new method in local/lib/Ticket_Overlay.pm like:

sub GetApprovers {
	my $self = shift;

	my $cf_value = $self->FirstCustomFieldValue( 'CF' );

	my $Users = RT::Users->new( self->CurrentUser );
	$Users->LimitCUstomField( CUSTOMFIELD => 'CF', VALUE => $cf_value );

	my @approvers;
	while ( my $User = $Users->Next) {
		push @approvers, $User->id;
	}
	return join(',', @approvers);

}

Then in the approval template, something like:

AdminCc: { $Tickets{TOP}->GetApprovers; }


NB:
- you can put all of the code in the template, but having an API method
is a bit better for code maintenance.
- double think of this, using groups is maybe a better idea
- not sure what arguments is accepted in AdminCc (list of users id,
email, ...), see lib/RT/Action/CreateTickets.pm


-- 
Easter-eggs                              Spécialiste GNU/Linux
44-46 rue de l'Ouest  -  75014 Paris  -  France -  Métro Gaité
Phone: +33 (0) 1 43 35 00 37    -   Fax: +33 (0) 1 43 35 00 76
mailto:elacour at easter-eggs.com  -   http://www.easter-eggs.com



More information about the rt-users mailing list