[rt-users] scrip not working

Gene LeDuc gleduc at mail.sdsu.edu
Tue Sep 4 11:47:27 EDT 2007


Hi Kenn,

Here's how I'd do it using my the set_custom function I use in my scrips:

set_custom("Work-Status", "Estimating Effort");

### Sets custom field value
### Usage: set_custom($field_name, $field_value, $record_transaction)
sub set_custom {
   my ($CFName, $CFValue, $record) = @_;
   my $cf = RT::CustomField->new($RT::SystemUser);
   my ($id,$msg) = $cf->LoadByName(Name=>$CFName,);
   if (!$id) {
     $RT::Logger->debug("$MyName: Couldn't load CF ($CFName)");
     return undef;
   }
   ($id, $msg) = $Ticket->AddCustomFieldValue
      (Field=>$cf, Value=>$CFValue, RecordTransaction=>$record ? $record : 0);
}

It uses the AddCustomFieldValue method instead of 
AddValueForObject.  $record is 1 if you want the change to generate another 
transaction, 0 otherwise.

Gene

At 07:58 AM 9/4/2007, Kenneth Crocker wrote:
>$cf_obj->LoadByName( Name => $cf_name );
>$RT::Logger->debug( "Loaded \$cf_obj->Name = ". $cf_obj->Name() ."\n" );
>$cf_obj->AddValueForObject( Object=>$ticket, Content=>$cf_value, );
>
>return 1;
>
>         When I change the ticket status to "open", nothing happens. I do 
> have a notification scrip that produces an E_mail notification based on 
> the same user-defined condition and that works. But nothing else is 
> getting done. Any ideas as to why? I have another scrip similar to this 
> one (different Custom field modified and for only 1 particulat queue) and 
> it doesn't work either. Thanks in advance.


-- 
Gene LeDuc, GSEC
Security Analyst
San Diego State University 




More information about the rt-users mailing list