[rt-users] Fwd: How to Assign a value to a Custom Field using Requestor Real Name

Joe Kirby (gmail) kirby at umbc.edu
Thu Feb 10 13:25:19 EST 2011


My users would like to have reports on their RT-at-a-Glance page which 
would parse out their tickets from several queues into a report grouped 
by the requestors initial of their last name.

For example group 1 may be A-F, Group 2 G-K, etc.

I was thinking of having a Custom Field associated with their queues 
that was set at time of entry and then have the report use that value in 
this field (A-Z) to select records

My problem is that I do not know the field name for the Requestors Real 
Name as indicated in the ?? marks below.

Additionally, I am VERY open if someone has a better idea.

Below is the script I was going to have exec at New Ticket entry

Any help is greatly appreciated

Thanks

Joe

my $CFName = 'Last Name

Grouping';
my $RecTransaction = 1;


  my $QueueObj =

$self->TicketObj->QueueObj;
  my $CFObj =

RT::CustomField->new( $QueueObj->*??Requestor.RealName??

*);


  $CFObj->LoadByNameAndQueue( Name => $CFName, Queue

=> $QueueObj->id );
  unless( $CFObj->id ) {


    $RT::Logger->warning("custom field '$CFName' isn't

defined for queue '". $QueueObj->Name ."'");
    return undef;
  }



  my $RequestorRealName = '*??Requestor.RealName??*';
  my $LastInitial =

substr($RequestorRealName ,instr($RequestorRealName ,'

',-1,1)+1,1);

  unless(

$self->TicketObj->FirstCustomFieldValue( $CFObj->id )

) {
    my( $st, $msg ) =

$self->TicketObj->AddCustomFieldValue(


                                          Field =>

$CFObj->id,


                                          Value =>

$LastInitial,


                                          RecordTransaction

=> $RecTransaction );
    unless( $st ) {


      $RT::Logger->warning( "Couldn't set $DefaultValue as

value for CF $CFName:". $msg );
      return undef;
    }
  }

  return 1;

-- 
Joe Kirby , Assistant Vice President, Business Systems
Division of Information Technology (DoIT)
Support Response -http://www.umbc.edu/oit
Administration 627
Office - 410-455-3020
Email -kirby at umbc.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110210/0318f35d/attachment.htm>


More information about the rt-users mailing list