How to add a group

Hi everyone.

I want to add a group (defined inside RT) in a script ?

I find something on the web who use de AddWatcher like something :

my $addGroupObj = RT::Group->new($RT::SystemUser);
$addGroupObj->LoadUserDefinedGroup(‘My Group’);
return undef unless $addGroupObj;
my $addGroupMembersObj = $addGroupObj->UserMembersObj;

my $userObj;
while ($userObj = $addGroupMembersObj->Next) {
if (($ticket->IsRequestor($userObj->PrincipalId)) or ($ticket->IsAdminCc($userObj->PrincipalId))) {
$RT::Logger->debug(“Add Group AdminCC: '” . $userObj->Name . “’ is already a ticket watcher; not adding AdminCc on ticket #” . $ticket->id );
} else {
$RT::Logger->debug(“On Create Add Group AdminCC: Adding '” . $userObj->Name .“’ to ticket #” .$ticket->id);
my ($success, $msg)= $ticket->AddWatcher(
Type => “AdminCc”,
PrincipalId => $userObj->PrincipalId);
if (! $success) {
$RT::Logger->info(“On Create Add Group Addmin CC: couldn’t add '” . $userObj->Name . “’ to " . $ticket->id . “': got '” . $msg .”'");
}
}
}
return 1

but that’s no very convenient, I like to add directly a group.

Regards.

JAS

Albert SHIH
DIO b�timent 15
Observatoire de Paris
5 Place Jules Janssen
92195 Meudon Cedex
France
T�l�phone : +33 1 45 07 76 26/+33 6 86 69 95 71
xmpp: jas@obspm.fr
Heure local/Local time:
mer 10 sep 2014 16:05:17 CEST

Hi everyone.

I want to add a group (defined inside RT) in a script ?

I find something on the web who use de AddWatcher like something :

my ($success, $msg)= $ticket->AddWatcher( 
            Type => "AdminCc",            
            PrincipalId => $userObj->PrincipalId);

but that’s no very convenient, I like to add directly a group.

What happened when you passed the group’s PrincipalID?
Since that will work (for things other than Owner).

-kevin