On Fri, Jul 13, 2012 at 10:01:33AM +0100, Tim Cutts wrote:
>
> On 13 Jul 2012, at 01:01, Richard McMahon wrote:
>
> > OK, that gets me the queue list.
> >
> > Is there an API way to get the full list of valid status values
>
> That's part of the configuration; it's not an API as such. That information
> is all configurable by you in the %Lifecycle configuration (look in
> RT_Config.pm).
>
> See the documentation for the RT::Lifecycle module:
>
> my $lifecycle = RT::Lifecycle->Load('default');
> my @statuses = $lifecycle->Valid;
>
> probably gets you what you want. Most of the perl classes that the
> BestPractical guys expect us to use in scripts have reasonable pod
> documentation, although often you have to remember to also consult the
> superclass documentation as well, since sometimes the documentation is at
> that level, in things like RT::Record and RT::SearchBuilder.You really don't want to go about it that way. You want to ask the Queue for the valid statuses, which is why I pointed to the perldoc for Queue.pm. A Queue object can get you both global and queue specific sets of statuses, and it can also tell you if a Status is valid for a given Queue. > > and also > > the list of names of ticket owners. > > Well, you can always construct that from any list of tickets that you've > previously obtained. The method is similar to the one mentioned before for > iterating over queues; instead, you iterate over the tickets and fetch the > name of the owner from each one. Note that this is likely to be quite slow > if there are a lot of tickets. > > You could, of course query the database directly, with something like: > > select distinct(u.Name) from Users u, Tickets t where t.Owner = u.id; > > but querying the database directly is not generally considered a smart thing > to do, although I doubt this part of the schema is going to change any time > soon. This is a list of people who are currently Owners, which is not actually the same as people who can be owners. -kevin > > I have looked that the code > > that Ruslan mentions but I am able see how to get at the owner > > list and list of valid status values. > > I find that most of the RT code base itself is usually fairly clear (with the > exceptions of some of the hairier web interface corners), and when I want to > find out how to do something in the RT API I just search the main RT code for > places where the same thing is being done, and copy it!
pgpdXuQMJ7vkU.pgp
Description: PGP signature
