[rt-users] Add GroupMembers as CC on create ( help required )

Roy Sowa Roy.Sowa at rcmp-grc.gc.ca
Thu Dec 6 16:17:06 EST 2007


First off, my apologizes for posting to the dev list earlier in error... a true newbie 
 I need some guidance..


I have tried numerous versions of scrips , approaches and examples that I have found thanks to this list, 
but I just can't get things to work as I expect/want.
The below scrip ( found on the list...thank you ) , does work , but it requires that I have the hardcoded "Group_Here_Works" entry.
Usin different group names does produce those members as CC's.

What I really want to have happen is;
  the requestor's group/s members be automatically figured out and  those members be added as CC's to the ticket on creation.

 but I can't seem to grasp how. 

I am struggling to get my head around all this, so any assistance is very welcomed.

==============================
my $ticket = $self->TicketObj;
my $transaction = $self->TransactionObj;

my $derivedGroupName = 'GROUPNAME_HERE_WORKS';

# instantiate a group object
my $addGroupObj = RT::Group->new($RT::SystemUser);
$addGroupObj->LoadUserDefinedGroup($derivedGroupName);
return undef unless $addGroupObj;
my $addGroupMembersObj = $addGroupObj->UserMembersObj;

my $userObj;
# walk through members of group to add; if a given member is not already on the ticket, add to the CC list
while ($userObj = $addGroupMembersObj->Next) {
    if (($ticket->IsRequestor($userObj->PrincipalId)) or ($ticket->IsCc($userObj->PrincipalId))) {
        $RT::Logger->debug("On Create Add Group CC: '" . $userObj->Name . "' is already a ticket watcher; not adding Cc on ticket \#" . $ticket->id );
    } else {
	$RT::Logger->debug("On Create Add Group CC: Adding '" . $userObj->Name ."' to ticket \#" .$ticket->id);
	my ($success, $msg)= $ticket->AddWatcher( 
						  Type => "Cc", 
						  PrincipalId => $userObj->Id);
	if (! $success) {
	    $RT::Logger->info("On Create Add Group CC: couldn't add '" . $userObj->Name . "' to " . $ticket->id . "': got '" . $msg ."'");
	}
    }
}
return 1;





More information about the rt-users mailing list