[rt-users] Scrips - accessing "requestor" name from a ticket that has just b een created

Maciak, TJ tmaciak at ci.grand-rapids.mi.us
Tue Jul 12 16:50:21 EDT 2005


So sorry.. I found out how to get what I wanted :)
 
$RT::Logger->debug( "COGR - testscript #21");
 
my $department = "unknown";
my $requestor=$self->TransactionObj->Creator;
 
if ($requestor) {
  my $UserObj = RT::User->new( $RT::SystemUser );
  $UserObj->Load($requestor);
  $department = $UserObj->FirstCustomFieldValue('Department');
}
 
$RT::Logger->debug( "COGR - testscript #21 for requestor: " .
$self->TransactionObj->Creator ." department: " . $department);
 
return undef;

T.J. Maciak

Internet/Intranet Developer
Department of IT
City of Grand Rapids
P: (616)456-3713
F: (616)456-3448


 

  _____  

From: rt-users-bounces at lists.bestpractical.com
[mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Maciak, TJ
Sent: Tuesday, July 12, 2005 4:32 PM
To: rt-users at lists.bestpractical.com
Subject: RE: [rt-users] Scrips - accessing "requestor" name from a ticket
that has just b een created


Ok I have updated my script because I found out how to get the ID of the
requestor.
 
Now I am having trouble getting the UserObj:
 
== START
 
$RT::Logger->debug( "COGR - testscript #21");
 
my $department = "unknown";
my $requestor=$self->TransactionObj->Creator;
 
if ($requestor) {
#   my $UserObj = new RT::User($session{'CurrentUser'});
   my $UserObj = RT::User->new(RT::CurrentUser->new('CurrentUser'));
   $UserObj->Load($requestor->id) if defined($requestor);
 
 $department = $UserObj->FirstCustomFieldValue('Department');
}
 
$RT::Logger->debug( "COGR - testscript #21 for requestor: " .
$self->TransactionObj->Creator ." department: " . $department);
 
return undef;

== END
 
With this I get:
[Tue Jul 12 20:27:28 2005] [error]: Scrip 21 Commit failed: Can't call
method "id" without a package or object re
ference at (eval 754) line 15, <GEN131> line 53.
 
With #my $UserObj = new RT::User($session{'CurrentUser'}); in the code
commented "IN", I get:
[Tue Jul 12 20:19:31 2005] [error]: Scrip 21 Commit failed: Global symbol
"%session" requires explicit package na
me at (eval 689) line 13, <GEN120> line 53.
 
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)?
 
T.J. Maciak

Internet/Intranet Developer
Department of IT
City of Grand Rapids
P: (616)456-3713
F: (616)456-3448


 

  _____  

From: rt-users-bounces at lists.bestpractical.com
[mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Maciak, TJ
Sent: Tuesday, July 12, 2005 3:30 PM
To: rt-users at lists.bestpractical.com
Subject: [rt-users] Scrips - accessing "requestor" name from a ticket that
has just b een created


I have written a scrip that states following:
 
Description: Add Department to Ticket
Condition: On Create
Action: User Defined
Template: Global Template: Blank
Stage: Transaction Create
 
Custom condition: none
Custom action preparation code: return 1;
Custom action cleanup code:
$RT::Logger->debug( "COGR - testscript #21");
 
my $people = $Ticket->Requestors->UserMembersObj;
my $requestor=$people->Next || undef
 
my $department = "unknown";
 
if ($requestor) {
 $UserObj->Load($requestor->id);
 $department = $UserObj->FirstCustomFieldValue('Department');
}
$RT::Logger->debug( "COGR - testscript #21 for department: $department");
return undef;

=========================================================
 
Now I want to fetch the "Requestors" field of a new ticket with this on
create scrip, then lookup that
requestor and grab a custom field (Department) and then place it in another
object related to the ticket called "DepartmentTicket".
 
However, $Ticket doesnt yet exist (at least I dont think so), so how would I
go about grabbing
the requestor field from the Create.html file?
 
Thanks,
 
T.J. Maciak

Internet/Intranet Developer
Department of IT
City of Grand Rapids
P: (616)456-3713
F: (616)456-3448


 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20050712/643ae2e0/attachment.htm>


More information about the rt-users mailing list