[rt-users] Custom field not mandatory in all queues
Macnlos
macnlos at ti-994a.com
Fri Feb 6 16:47:56 EST 2009
This is a code example where I'm checking to see if a CustomField
called "Application" has a value in it. If it doesn't then the
cleanup code changes the status back to OPEN and add a comment to the
ticket stating it was missing a value.
The Custom Action code has to handle that an update may involve
multiple transactions and you have to look at each transaction to if
one of them is going to update that field.
Hope that helps,
CR
-------------------------------
CONDITION: On Resolve
-------------------------------
ACTION: User Defined
-------------------------------
STAGE: TransactionBatch
-------------------------------
#CUSTOM ACTION PREPARATION
### See if there is a Transaction modifying Application field
my @batch= @{ $self->TicketObj->TransactionBatch };
foreach my $txn ( @batch ) {
my $txnType = $txn->Type;
my $txnDesc = $txn->Description;
if ($txnType eq 'CustomField') {
if ($txnDesc =~ /^Application/) {
return 0; # There is a transaction updating Application so
don't run
}
}
}
### Get the Application value
my $CFV = $self->TicketObj->FirstCustomFieldValue('Application');
### Choose whether to run script
if ($CFV) {
return 0; # There is a value so don't execute scrip
}
if ($self->TicketObj->QueueObj->Name eq 'Server') {
return 0; # Skipping the Server queue
}
else {
return 1; # There isn't a value so execute scrip
}
return 0;
-------------------------------
#CUSTOM ACTION CLEANUP
### Set ticket status to open
my ($status, $msg) = $self->TicketObj->SetStatus( 'open' );
unless( $status ) {
$RT::Logger->error( "ERROR - NoApplication SCRIP: $msg" );
return undef;
}
### Add a comment to the ticket
$self->TicketObj->Comment( Content => 'Missing Custom Field Value -
Application! - Status has been changed to OPEN');
return 1;
-------------------------------
On Feb 6, 2009, at 3:30 PM, Laura Grella wrote:
>
> Thanks Kenn,
>
> It has been at least 6 months since I have done any scrip coding and
> was
> wondering if you had any sample code that would check the field and
> return 0
> when empty? I'd really appreciate it.
>
> Thanks,
> Laura
>
> Kenneth Crocker wrote:
>>
>> Laura,
>>
>> I'm only on 3.6.4 so my comment may be out of date. I don't think
>> that's possible in configuration. If a CF is set up to be mandatory,
>> then whenever it is applied to a queue, those tickets will require an
>> entry. What you can do is remove the "Mandatory" setting and then
>> write
>> a scrip for the queues you want it to be mandatory in and do a
>> return 0
>> when checking it against the desired transactions and it is empty.
>> Hope
>> this helps.
>>
>>
>> Kenn
>> LBNL
>>
>> On 2/6/2009 12:33 PM, Laura Grella wrote:
>>> Is there a way to make a custom field mandatory in 3 queues, but not
>>> mandatory in a 4th queue?
>>>
>>> Thanks,
>>> Laura
>>
>> _______________________________________________
>> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>>
>> Community help: http://wiki.bestpractical.com
>> Commercial support: sales at bestpractical.com
>>
>>
>> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
>> Buy a copy at http://rtbook.bestpractical.com
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Custom-field-not-mandatory-in-all-queues-tp21880139p21880998.html
> Sent from the Request Tracker - User mailing list archive at
> Nabble.com.
>
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090206/ae0ea73d/attachment.htm>
More information about the rt-users
mailing list