<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>Ok I have updated my script because I found out how to
get the ID of the requestor.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>Now I am having trouble getting the
UserObj:</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>== START</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>$RT::Logger->debug( "COGR - testscript
#21");</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>my $department = "unknown";<BR>my
$requestor=$self->TransactionObj->Creator;</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>if ($requestor) {<BR># my $UserObj = new
RT::User($session{'CurrentUser'});<BR> my $UserObj =
RT::User->new(RT::CurrentUser->new('CurrentUser'));<BR>
$UserObj->Load($requestor->id) if defined($requestor);</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005> $department =
$UserObj->FirstCustomFieldValue('Department');<BR>}</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>$RT::Logger->debug( "COGR - testscript #21 for
requestor: " . $self->TransactionObj->Creator ." department: " .
$department);</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>return undef;<BR></SPAN></FONT><FONT face=Arial
color=#0000ff size=2><SPAN class=126182920-12072005></SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005>== END</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=126182920-12072005>With
this I get:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=126182920-12072005>[Tue
Jul 12 20:27:28 2005] [error]: Scrip 21 Commit failed: Can't call method "id"
without a package or object re<BR>ference at (eval 754) line 15, <GEN131>
line 53.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=126182920-12072005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=126182920-12072005>With
#my $UserObj = new RT::User($session{'CurrentUser'}); in the code commented
"IN", I get:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=126182920-12072005>[Tue
Jul 12 20:19:31 2005] [error]: Scrip 21 Commit failed: Global symbol "%session"
requires explicit package na<BR>me at (eval 689) line 13, <GEN120> line
53.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=126182920-12072005>Any
ideas on how I can get access to $UserObj so I can load the ID of that user and
then grab their department (custom field)?</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV align=left><SPAN style="FONT-FAMILY: times new roman"><FONT face=Arial
size=2>T.J. Maciak</FONT></SPAN></DIV><SPAN
style="FONT-FAMILY: times new roman">
<DIV align=left><BR><FONT face=Arial size=2>Internet/Intranet
Developer<BR>Department of IT<BR>City of Grand Rapids<BR>P:
(616)456-3713</FONT></DIV>
<DIV align=left><FONT face=Arial size=2>F:
(616)456-3448<BR><BR></DIV></FONT></SPAN>
<DIV> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] <B>On Behalf Of </B>Maciak,
TJ<BR><B>Sent:</B> Tuesday, July 12, 2005 3:30 PM<BR><B>To:</B>
rt-users@lists.bestpractical.com<BR><B>Subject:</B> [rt-users] Scrips -
accessing "requestor" name from a ticket that has just b een
created<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>I have written a
scrip that states following:</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Description: Add
Department to Ticket</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Condition: On
Create</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Action: User
Defined</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Template: Global
Template: Blank</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Stage: Transaction
Create</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Custom condition:
none</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Custom action
preparation code: return 1;</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Custom action
cleanup code:</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial
size=2>$RT::Logger->debug( "COGR - testscript #21");</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>my $people =
$Ticket->Requestors->UserMembersObj;<BR>my $requestor=$people->Next ||
undef</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>my $department =
"unknown";</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>if ($requestor)
{<BR> $UserObj->Load($requestor->id);<BR> $department =
$UserObj->FirstCustomFieldValue('Department');<BR>}<BR>$RT::Logger->debug(
"COGR - testscript #21 for department: $department");</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>return
undef;<BR></FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial
size=2>=========================================================</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>Now I want to fetch
the "Requestors" field of a new ticket with this on create scrip, then lookup
that</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>requestor and grab a
custom field (Department) and then place it in another</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>object related to
the ticket called "DepartmentTicket".</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>However, $Ticket
doesnt yet exist (at least I dont think so), so how would I go about
grabbing</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial size=2>the requestor field
from the Create.html file?</FONT></SPAN></DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=642332519-12072005><FONT face=Arial
size=2>Thanks,</DIV></FONT></SPAN>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><SPAN style="FONT-FAMILY: times new roman"><FONT face=Arial
size=2>T.J. Maciak</FONT></SPAN></DIV><SPAN
style="FONT-FAMILY: times new roman">
<DIV align=left><BR><FONT face=Arial size=2>Internet/Intranet
Developer<BR>Department of IT<BR>City of Grand Rapids<BR>P:
(616)456-3713</FONT></DIV>
<DIV align=left><FONT face=Arial size=2>F:
(616)456-3448<BR><BR></DIV></FONT></SPAN>
<DIV> </DIV></BODY></HTML>