[rt-users] Set priority based on requestor's group membership

Steve Hopps steve.hopps at gmail.com
Thu May 28 14:59:03 EDT 2009


This worked exactly right. I used =~ instead of eq, and otherwise just cut
and pasted your code. Thank you so much!!
-S

On Thu, May 28, 2009 at 12:02 PM, Raed El-Hames <rfh at vialtus.com> wrote:

> Just finished working on something very similar , I am guessing the top
> sales guys would be the one creating a ticket, if this is the case you can
> do a scrip:
>
>
> my $CreatorObj = $self->TicketObj->CreatorObj ;
> my $org = $CreatorObj->GroupMembership ;
>
> if ( $org  eq 'The group you need') {
>   $self->TicketObj->SetPriority(80);
> }
> return undef;
>
> The function GroupMembership I created in User_Vendor.pm (or
> User_Overlay.pm pending which ever you are using):
>
> sub GroupMembership {
>       # Identify a group\s a user belong to
>       # Used in scrip action in queues
>
>       # Expects a user id and return group name
>       # If user belong to more than one it returns comma seperated list
>
>       my $self = shift;
>       my $MemberId = $self->Id ;
>
>       my $group_list = '';
>
>       my $Groups = RT::Groups->new($RT::SystemUser);
>       $Groups->Limit( FIELD => 'Domain',OPERATOR => '=', VALUE =>
> 'SystemInternal');
>       $Groups->Limit( FIELD => 'Domain',OPERATOR => '=', VALUE =>
> 'UserDefined');
>
>       my $alias = $Groups->Join(
>               TYPE       => 'left',
>               ALIAS1     => 'main',
>               FIELD1     => 'id',
>               TABLE2     => 'GroupMembers',
>               FIELD2     => 'GroupId'
>       );
>       $Groups->Limit(
>               ALIAS      => $alias,
>               FIELD      => 'MemberId',
>               OPERATOR   => '=',
>               VALUE      => $MemberId,
>       );
>
>       while ( my $Group = $Groups->Next ) {
>               $group_list = $group_list.",".$Group->Name ;
>
>       }
>       $group_list =~ s/^,+// ;
>       return $group_list ;
> }
>
>
> I am not 100% on the SetPriority syntax -you may need to check it--, we do
> n't use priority we use custom fields resembling priority.
> Also note  if the Creator (person) is a member of more than one group then
> the $org will be list of group names separated by a comma , in that case you
> maybe better off doing:
> if ( $org  =~ /The group name you need/) {
>   $self->TicketObj->SetPriority(80);
> }
>
> Regards;
> Roy
>
>
>
> Steve Hopps wrote:
>
>> Hi there, at our company there's a group of people who get preferential
>> treatment because they're top sales guys, and in order to make it easier on
>> our helpdesk techs, I'd like to have their tickets be prioritized
>> automatically based on membership to a group.
>>
>> I'm not sure how to do a check for group membership in a scrip, I've been
>> looking through the mail archives but haven't had any luck so far. Can
>> anyone recommend how to do this?
>>
>> Basically I want the scrip to trigger if they're a member, and set the
>> priority to something (say 80) on creation, and that's all. Any help would
>> be appreciated on this one. Thanks!
>>
>> -Steve
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090528/51ae1fc7/attachment.htm>


More information about the rt-users mailing list