[rt-users] Approval by group

William Faulk wfaulk at icoria.com
Mon Mar 14 10:07:27 EST 2005


Todd Chapman wrote:
> 
> I looked into the RT code and think I have an answer. RT is using the
> Action/CreateTickets.pm module to do this work. Looking at that
> code, the example suggest that AdminCc template field needs to be
> an e-mail address, but looking further it takes whatever you
> give it and feeds it as arguments to Ticket::Create(). Looking
> at that code (Ticket_Overlay.pm) we see that Create tries to do
> a LoadOrCreateByEmail for the AdminCcs _unless_ the AdminCc is
> a number, in which case it is the PrincipalId of the user/group.

That's quite the research.  Thanks.

> So this is what I would try in your template:
> 
> AdminCc: {RT::Group->new($RT::SystemUser)->Load("Unix")->PrincipalId()}

This fails to create the approval at all.  Looking in the syslog, it's 
listing the errors:

> RT: Group -> Load called with a bogus argument (/usr/local/rt3/lib/RT/Group_Overlay.pm:265)
> RT: Ticket creation failed: Can't call method "PrincipalId" on an undefined value at template line 5.

Unix is definitely the name of the group.  Maybe that's not the right 
argument?  Yeah.  Group->Load() takes an ID, which is what we're trying 
to get.  Some trial and error reveals that this works, though:

> AdminCC: {$g = RT::Group->new($RT::SystemUser), $g->LoadUserDefinedGroup("Unix"), $g->id}

I couldn't get it to work as one statement, so I had to split it up like 
that.

Both "RT::Group->new($RT::SystemUser)->LoadUserDefinedGroup("Unix")->id" 
and "$g = RT::Group->new($RT::SystemUser)->LoadUserDefinedGroup("Unix"), 
$g->id" generated errors about "Can't locate object method "id" via 
package "Found Object" (perhaps you forgot to load "Found Object"?) at 
template line 5".  Splitting it up fixes it, though, and places the 
correct thing in the AdminCC field on the approval; it lists the group 
and all the members of the group.

Thanks so much for your help.  I'm going to put this in the Wiki.

-Bitt



More information about the rt-users mailing list