Assets as CF SourceValues

46 views
Skip to first unread message

rem...@gmail.com

unread,
Oct 28, 2013, 9:24:37 AM10/28/13
to at-u...@googlegroups.com

Per the documentation below, I have added the CF SourceValues to my RT_SiteConfig.pm and I have selected the option for Field values source: but I am not able to get any results from the database for this custom field. Is there anything else needed to be able to pull a list of the  Assets that I have entered into the database?

The Drop down for the custom field created is named "DR Servers from CMDB"  is this a default configuration, I have tried changing the Values but without any luck.


"If you like to use Assets as CF SourceValues, you can activate it as example like this inside
RT_SiteConfig.pm:

Set(@CustomFieldValuesSources, (qw(RT::CustomFieldValues::ATServers)));"

gfranzini

unread,
Oct 28, 2013, 12:33:16 PM10/28/13
to at-u...@googlegroups.com
Hello,
you have to create a file named after the source, ATServers.pm in your case.
Here is an example for a source called ATPC, query at line 27 must be adjusted to fit your situation:

package RT::CustomFieldValues::ATPC;

# Activate this CFSource via RT_SiteConfig.pm
# Set(@CustomFieldValuesSources, (qw(RT::CustomFieldValues::ATPC)));

use base qw(RT::CustomFieldValues::External);
use RT;
use RTx::AssetTracker::Asset;
use RTx::AssetTracker::Type;

RT::LoadConfig();
RT::Init();
my $at = RTx::AssetTracker::Asset->new(RT->SystemUser);
my $attype = RTx::AssetTracker::Type->new(RT->SystemUser);


sub SourceDescription {
        return 'Test: Info dagli asset di tipo PC';
}


sub ExternalValues {
                my $self = shift;
                my @res;
                my $i = 0;
                my $assets = RTx::AssetTracker::Assets->new($RT::SystemUser);
                my $query = "Status != 'retired' AND Type = 'PC'";
                my ($id, $msg)  = $assets->FromSQL($query);

                while (my $asset = $assets->Next) {
                        my $assdisc = $asset->Description;
                        my $assname = $asset->Name;
                        push @res,
                                {
                                        name => $assname,
                                        description => $assdisc,
                                        sortorder   => $i++,
                        };

                }

return \@res;
}

RT::Base->_ImportOverlays();

1;
 ---------------------------------------------
HTH,
Gabriele

rem...@gmail.com

unread,
Oct 28, 2013, 1:03:48 PM10/28/13
to at-u...@googlegroups.com

Thanks for the information, I would have never know that if you hadn't posted your reply.

Is this information listed some place that I may not be reading?

Milan Toth

unread,
Oct 28, 2013, 1:07:49 PM10/28/13
to at-u...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "at-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to at-users+u...@googlegroups.com.
To post to this group, send email to at-u...@googlegroups.com.
Visit this group at http://groups.google.com/group/at-users.
For more options, visit https://groups.google.com/groups/opt_out.

rem...@gmail.com

unread,
Oct 28, 2013, 3:08:43 PM10/28/13
to at-u...@googlegroups.com
Thanks,

I did manage to find it on RT's site after asking the question, now just need to understand the perl better
Reply all
Reply to author
Forward
0 new messages