Hello to all.
I have to develop a plugin for RTIR to collect X data from an RT article.
I have managed to access the basic content of the article through the RT::Article module but I can’t manage to show the content of the article which is what I’m really interested in.
Do you have any suggestions please?
Thank you very much and best regards.
The article content is stored as a Custom Field called “Content”, attached to the Article object. As RT::Article
inherits from RT::Record
in a similar way that RT::Ticket
does, you can use methods from RT::Record
to access and manipulate the custom field.
Here’s a simple example script that will get the name and contents (if any) of an article for you given its ID on the command line:
#!/usr/bin/perl
use strict;
use warnings;
use lib '/opt/rt5/lib';
use lib '/opt/rt5/etc';
use lib '/opt/rt5/local/lib';
use lib '/opt/rt5/local/etc';
use RT -init;
use RT::Article;
my $currentUser = RT::CurrentUser->new(RT::SystemUser);
my $article = RT::Article->new( $currentUser );
my $articleId = shift || 1;
$article->Load($articleId);
print "Name: ".$article->Name()."\n";
print $article->CustomFieldValuesAsString("Content")."\n";
Thank you very much for your reply @GreenJimll, it works perfectly :-).