[rt-users] Assets for RT (RT::Extension:Assets) - Help with perl script

Emmanuel Lacour elacour at easter-eggs.com
Fri Apr 10 13:02:23 EDT 2015


Le 10/04/2015 13:06, Carl van Litsenborgh a écrit :
>
> I have a standard installation of RT4 with the extension 
> RT::Extension:Assets added.
>
> I wrote a perl script (based on the many examples on the RT WIKI 
> contributions pages) to scan through all open tickets reporting (in 
> HTML) certain key performance indicators for me.
>
> I would like to extend this perl script to ALSO scan through all 
> “assets” in my RT database and to report on the content of a certain 
> asset custom field (call it Asset_Status).
>
> I have searched the mailing lists and internet for some guidance, but 
> found none.
>
> Can someone please help me (or guide me) with a perl code snippet 
> showing the basics of how to loop (in perl API) through all assets in 
> RT, and to extract the information (text field) of s specific custom 
> field assigned to all assets to get me started.
>
>

something like:

my $Catalog = RT::Catalog->new( RT->SystemUser );
$Catalog->Load('Informatique');

my $Assets = RT::Assets->new( RT->SystemUser );
$Assets->LimitCatalog(VALUE => $Catalog->id);

my $CustomField = RT::CustomField->new( RT->SystemUser );
$CustomField->LoadByName( Name => 'Marque', LookupType => 
'RT::Catalog-RT::Asset' );
$Assets->LimitCustomField( CUSTOMFIELD => $CustomField->id, VALUE => 
'CANON' );

print "Found: ".$Assets->Count." asset(s)\n";

while (my $Asset = $Assets->Next) {
     print "Found asset number: ".$Asset->id."\n";
}


-- 
Easter-eggs                              Spécialiste GNU/Linux
44-46 rue de l'Ouest  -  75014 Paris  -  France -  Métro Gaité
Phone: +33 (0) 1 43 35 00 37    -   Fax: +33 (0) 1 43 35 00 76
mailto:elacour at easter-eggs.com  -   http://www.easter-eggs.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20150410/5952f952/attachment.htm>


More information about the rt-users mailing list