Re: [rt-users] RT Approvals

2015-09-18 Thread Todd Wade

On 9/11/15 9:47 AM, Kobus Bensch wrote:

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?


Note this section of the documentation:

https://www.bestpractical.com/docs/rt/latest/customizing/approvals.html#Approvers

Where it says:

Requestors: {$Tickets{TOP}->RequestorAddresses}

The content in the brackets is perl code. And it also talks about 
different ways you can assign to people or notify different groups.


So combining that, you can put some code in for the AdminCcGroup: value 
(or whatever would fit your workflow) to programmatically determine who 
to send the approval to:


AdminCcGroup: { $Tickets{TOP}->FirstCustomFieldValue('ApprovalGroup') }

Regards,



Re: [rt-users] RT Approvals

2015-09-14 Thread Emmanuel Lacour
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:elac...@easter-eggs.com  -   http://www.easter-eggs.com