To list,

I have a Custom Field I use as a "To" address for Others in a template; To:
{$Ticket->FirstCustomFieldValue('QA Approver')}

This CF is a "Select One Value" type.

Now I have a situation that is similar, except that there will be more than
one address to use. I figured I'd define the CF as "Enter Multiple values"
and write a scrip to build those values. The email addresses would come from
a group.

This is what I have so far:
===================================================
# set up initial values

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $GroupName = "Test Group";

# set up Group Objects

my $GroupObj = RT::Group->new($RT::SystemUser);
$GroupObj->LoadUserDefinedGroup($GroupName);

# get out if wrong Group

return 0 unless $GroupObj;

# Walk thru Group and add an email address for that member

my $cf_name = "Test-Team";
my $GroupMembersObj = $GroupObj->UserMembersObj;
my $UserObj;

while ($UserObj = $GroupMembersObj->Next)
      {
       my $UserEmail = $UserObj->EmailAddress|(", ");
       my $cf_obj = RT::CustomField->new($RT::SystemUser);
       $cf_obj->LoadByName(Name=>$cf_name);
       $RT::Logger->debug("Loaded\$cf_obj->Name = ". $cf_obj->Name() ."\n");
       $ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$UserEmail,
RecordTransaction=>0);
      }

return 1;
=====================================================================

I'm ending up with values for each member, but they are messed up. The first
letter of the email address is bogus. I was hoping to get a string of values
separated by that comma so I could just plug the CF into the template.

I checked the log and no errors or warnings are showing up (Ruslan, I KNEW
you'd ask that right off ;-).

Any help would be GREATLY appreciated.

Kenn
LBNL
--------
RT Training Sessions (http://bestpractical.com/services/training.html)
*  Chicago, IL, USA — September 26 & 27, 2011
*  San Francisco, CA, USA — October 18 & 19, 2011
*  Washington DC, USA — October 31 & November 1, 2011
*  Melbourne VIC, Australia — November 28 & 29, 2011
*  Barcelona, Spain — November 28 & 29, 2011

Reply via email to