[rt-users] getting the values of custom fields
Joe Casadonte
joe.casadonte at oracle.com
Tue Feb 13 16:46:07 EST 2007
On 2/13/2007 3:09 PM, anthony wrote:
> Where are you doing this the webui?
The following worked for me in 3.6.3 (Note: this is NOT through the
WebUI -- not sure if it will help you or not):
sub IsApplicable
{
my($self) = shift;
my($CFNAME) = 'Severity';
my($q) = $self->TicketObj->QueueObj;
my($cf) = new RT::CustomField $q->CurrentUser;
$cf->LoadByNameAndQueue(Name => $CFNAME, Queue => $q->id);
$cf->LoadByNameAndQueue(Name => $CFNAME, Queue => 0) unless $cf->id;
unless ($cf->id) {
$RT::Logger->warning("Custom field '$CFNAME' isn't global or defined
for queue '" . $q->Name . "'");
return undef;
}
return ! $self->TicketObj->FirstCustomFieldValue($cf->id);
}
and:
sub Prepare
{
my($self) = shift;
my($CFNAME) = 'Severity';
my($CFDEFVAL) = 'Medium';
my($q) = $self->TicketObj->QueueObj;
my($cf) = new RT::CustomField $q->CurrentUser;
$cf->LoadByNameAndQueue(Name => $CFNAME, Queue => $q->id);
$cf->LoadByNameAndQueue(Name => $CFNAME, Queue => 0) unless $cf->id;
my($rc, $msg) = $self->TicketObj->AddCustomFieldValue(Field => $CFNAME,
Value => $CFDEFVAL,
RecordTransaction => 1);
unless ($rc) {
$RT::Logger->warning("Could not set '$CFNAME' to '$CFDEFVAL': $msg");
return undef;
}
return 1;
}
--
Regards,
joe
Joe Casadonte
joe.casadonte at oracle.com
More information about the rt-users
mailing list