Recording user/requestor attributes in ticket custom fields

Hi all,

I’m running RT 3.8.7 on Ubuntu 10.04 for a couple of months now so am
fairly comfortable with the basics. I’d like to be able to record
requestor info in custom fields with a ticket so that when an engineer
is assigned the ticket this info can be part of the summary mailed to
them.

I’ve read that I can do this via a scrip and already have custom fields
being set to default values but I can’t figure out what objects(Is this
the correct term?) to set my user info custom field to?

What I’m asking is pretty much the same as here
http://www.gossamer-threads.com/lists/rt/users/98591 but I rather not
use the callbacks just yet - I’d like to get my head around scrips and
objects/variables first.

I found the code below and modified it slightly I can’t remember its
original function or where I found it for that matter but it was similar
to what I was after - I think! Unfortunately I’m not getting anything
stored in the Custom Field

my $T_Obj = $self->TicketObj;

my $requestor_address = $T_Obj->RequestorAddresses;

my $cf_value;

my $CF_Obj = RT::CustomField->new($self->CurrentUser);

my $cf_name = “CSM Name”; #change this to the CF name

$requestor_address =~ /(^.+)@([^.].*.[a-z]{2,}$)/;

$cf_name = $1

$CF_Obj->LoadByName( Name => $cf_name,);

$RT::Logger->debug( “Loaded $CF_Obj->Name = “. $CF_Obj->Name() .”\n” );

$CF_Obj->AddValueForObject( Object => $self->TicketObj,Content =>
$cf_value, );

return 1;

Can someone point me in the right direction is the code I’m using even
close?

Thanks in advance and let me know if you need more info,

Peter

Peter Nugent | Technical Director | +353 (0) 45-531262 | +353 (0) 45-940522
Leinster Mills | Osberstown | Naas | Co. Kildare | Ireland | mailto:peter.nugent@hetg.ie | http://www.hetg.ie

Hibernia Computer Services (KILDARE) T/A Hibernia Evros Technology Group Registered in Ireland No. 425932
Registered Office: Block G, Cherrywood Science & Technology Park, Loughlinstown, Co. Dublin

Hi all,

I’m running RT 3.8.7 on Ubuntu 10.04 for a couple of months now so am fairly comfortable with
the basics. I’d like to be able to record requestor info in custom fields with a ticket so
that when an engineer is assigned the ticket this info can be part of the summary mailed to
them.

I’ve read that I can do this via a scrip and already have custom fields being set to default
values but I can’t figure out what objects(Is this the correct term?) to set my user info
custom field to?

What I’m asking is pretty much the same as here
[1]http://www.gossamer-threads.com/lists/rt/users/98591 but I rather not use the callbacks
just yet - I’d like to get my head around scrips and objects/variables first.

I found the code below and modified it slightly I can’t remember its original function or
where I found it for that matter but it was similar to what I was after - I think!
Unfortunately I’m not getting anything stored in the Custom Field

You should be checking the return values of AddValueForObject.
my ($ok, $msg) = $CF_Obj etc etc
also, review docs/templates.pod for more about what info you can get
at in Templates

-kevin

Hi Kevin,

Thanks for replying so quickly I’ve read docs/templates.pod and now have
the requestor email address in the being returned in the mail. I’m not
so hot on the code though I just copied, pasted and swopped a few
obvious variables. I’m a bit lost when you say

“You should be checking the return values of AddValueForObject.
my ($ok, $msg) = $CF_Obj etc etc”

How do I even start to go about doing that? I’ve started to try teach
myself some basic Perl am I on the right track?

Thanks again,
Peter

Peter Nugent | Technical Director | +353 (0) 45-531262 | +353 (0) 45-940522
Leinster Mills | Osberstown | Naas | Co. Kildare | Ireland | mailto:peter.nugent@hetg.ie | http://www.hetg.ie

Hibernia Computer Services (KILDARE) T/A Hibernia Evros Technology Group Registered in Ireland No. 425932
Registered Office: Block G, Cherrywood Science & Technology Park, Loughlinstown, Co. Dublin

[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Kevin
FalconeSent: 17 February 2011 15:52
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Recording user/requestor attributes in ticket
custom fields

Hi all,

I’m running RT 3.8.7 on Ubuntu 10.04 for a couple of months now so
am fairly comfortable with
the basics. I’d like to be able to record requestor info in custom
fields with a ticket so
that when an engineer is assigned the ticket this info can be part
of the summary mailed to
them.

I’ve read that I can do this via a scrip and already have custom
fields being set to default
values but I can’t figure out what objects(Is this the correct
term?) to set my user info
custom field to?

What I’m asking is pretty much the same as here
[1]http://www.gossamer-threads.com/lists/rt/users/98591 but I
rather not use the callbacks
just yet - I’d like to get my head around scrips and
objects/variables first.

I found the code below and modified it slightly I can’t remember
its original function or
where I found it for that matter but it was similar to what I was
after - I think!
Unfortunately I’m not getting anything stored in the Custom Field

You should be checking the return values of AddValueForObject.
my ($ok, $msg) = $CF_Obj etc etc
also, review docs/templates.pod for more about what info you can get at
in Templates

-kevin

my $T_Obj = $self->TicketObj;

my $requestor_address = $T_Obj->RequestorAddresses;

my $cf_value;

my $CF_Obj = RT::CustomField->new($self->CurrentUser);

my $cf_name = “CSM Name”; #change this to the CF name

$requestor_address =~ /(^.+)@([^.].*.[a-z]{2,}$)/;

$cf_name = $1

$CF_Obj->LoadByName( Name => $cf_name,);

$RT::Logger->debug( “Loaded $CF_Obj->Name = “. $CF_Obj->Name()
.”\n” );

$CF_Obj->AddValueForObject( Object => $self->TicketObj,Content =>
$cf_value, );

return 1;

Can someone point me in the right direction is the code I’m using
even close?

Thanks in advance and let me know if you need more info,

Peter

Peter Nugent | Technical Director | +353 (0) 45-531262 | +353 (0) 

45-940522

Leinster Mills | Osberstown | Naas | Co. Kildare | Ireland |
[2]peter.nugent@hetg.ie |
[3]www.hetg.ie



Hibernia Computer Services (KILDARE) T/A Hibernia Evros Technology
Group Registered in Ireland
No. 425932
Registered Office: Block G, Cherrywood Science & Technology Park,
Loughlinstown, Co. Dublin

References

Visible links

  1. http://www.gossamer-threads.com/lists/rt/users/98591
  2. mailto:peter.nugent@hetg.ie
  3. http://www.hetg.ie/

Hi Kevin,

Thanks for replying so quickly I’ve read docs/templates.pod and now have
the requestor email address in the being returned in the mail. I’m not
so hot on the code though I just copied, pasted and swopped a few
obvious variables. I’m a bit lost when you say

“You should be checking the return values of AddValueForObject.
my ($ok, $msg) = $CF_Obj etc etc”

How do I even start to go about doing that? I’ve started to try teach
myself some basic Perl am I on the right track?

The line you quoted was me showing you how to check the return values.
Warn them out in an $RT::Logger->error() call

-kevin

Peter,

What User values do you want to save from the Requestor (I assume they are
on the User Table) and what are the corresponding Custom Fields for each of
those values and what “type” did you set the CF’s at?

Kenn
LBNLOn Thu, Feb 17, 2011 at 2:35 AM, Peter Nugent peter.nugent@hetg.ie wrote:

Hi all,

I’m running RT 3.8.7 on Ubuntu 10.04 for a couple of months now so am
fairly comfortable with the basics. I’d like to be able to record requestor
info in custom fields with a ticket so that when an engineer is assigned the
ticket this info can be part of the summary mailed to them.

I’ve read that I can do this via a scrip and already have custom fields
being set to default values but I can’t figure out what objects(Is this the
correct term?) to set my user info custom field to?

What I’m asking is pretty much the same as here
http://www.gossamer-threads.com/lists/rt/users/98591 but I rather not use
the callbacks just yet – I’d like to get my head around scrips and
objects/variables first.

I found the code below and modified it slightly I can’t remember its
original function or where I found it for that matter but it was similar to
what I was after – I think! Unfortunately I’m not getting anything stored in
the Custom Field

my $T_Obj = $self->TicketObj;

my $requestor_address = $T_Obj->RequestorAddresses;

my $cf_value;

my $CF_Obj = RT::CustomField->new($self->CurrentUser);

my $cf_name = “CSM Name”; #change this to the CF name

$requestor_address =~ /(^.+)@([^.].*.[a-z]{2,}$)/;

$cf_name = $1

$CF_Obj->LoadByName( Name => $cf_name,);

$RT::Logger->debug( “Loaded $CF_Obj->Name = “. $CF_Obj->Name() .”\n” );

$CF_Obj->AddValueForObject( Object => $self->TicketObj,Content =>
$cf_value, );

return 1;

Can someone point me in the right direction is the code I’m using even
close?

Thanks in advance and let me know if you need more info,

Peter

Peter Nugent | Technical Director | +353 (0) 45-531262 | +353 (0)
45-940522

Leinster Mills | Osberstown | Naas | Co. Kildare | Ireland |
peter.nugent@hetg.ie | www.hetg.ie


Hibernia Computer Services (KILDARE) T/A Hibernia Evros Technology Group
Registered in Ireland No. 425932
Registered Office: Block G, Cherrywood Science & Technology Park,
Loughlinstown, Co. Dublin