<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
------------------------------
Message: 2
Date: Mon, 13 Aug 2012 13:22:50 +0200
From: Gergely Buday <a class="moz-txt-link-rfc2396E" href="mailto:gbuday@gmail.com"><gbuday@gmail.com></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:rt-users@lists.bestpractical.com">rt-users@lists.bestpractical.com</a>
Subject: [rt-users] RT::User problem
Message-ID:
<a class="moz-txt-link-rfc2396E" href="mailto:CA+3iOzksxuc4T6hpwyX3=fAeHZsBPwxHyWm3T_-RMeX7UqWs-w@mail.gmail.com"><CA+3iOzksxuc4T6hpwyX3=fAeHZsBPwxHyWm3T_-RMeX7UqWs-w@mail.gmail.com></a>
Content-Type:
text/plain; charset=ISO-8859-1
Hi there,
I would like to create a User object through the Load method. The
documentation writes:
"Load a user object from the database. Takes a single argument. If
the argument is numerical, load by the column 'id'. If a user object
or its subclass passed then loads the same user by id. Otherwise,
load by the "Name" column which is the user's textual username."
#!/usr/bin/perl
use strict;
use lib "/opt/rt4/lib";
use lib "/opt/rt4/local/lib";
use RT;
use RT::User;
RT->LoadConfig;
RT->Init;
my $test_user = RT::User::Load('<a class="moz-txt-link-abbreviated" href="mailto:bg@buday-rd.hu">bg@buday-rd.hu</a>');
printf "\$test_user=", $test_user;
my @to = $test_user->EmailAddress;
for $a (0 .. $#to) { print $to[$a], "\n"; }
Running this script with sudo makes it say
[Mon Aug 13 11:16:47 2012] [crit]: Can't call method "EmailAddress"
on
an undefined value at ./email.pl line 13. (/opt/rt4/lib/RT.pm:341)
Can't call method "EmailAddress" on an undefined value at ./email.pl
line 13.
The username I used in the place of <a class="moz-txt-link-abbreviated" href="mailto:me@company.com">me@company.com</a> is indeed a valid
user name. What is the problem then?
- Gergely <br>
<br>
<blockquote
cite="mid:mailman.82.1344869503.4531.rt-users@lists.bestpractical.com"
type="cite">
</blockquote>
Hello Gergely, <br>
<br>
you can only load a user by id or by E-mail address. The routine is
LoadByEmail. <br>
<br>
<br>
Greetings, <br>
<br>
Wolfram<br>
<br>
<h2><a class="u"
href="https://rt-testsys-1/Developer/Perldoc/Body.html?n=RT::User#___top"
title="click to go to top of document" name="LoadByEmail"></a></h2>
</body>
</html>