[rt-users] RE Have a programatically set Custom Field trigger a Condition
Raphaël MOUNEYRES
raphael.mouneyres at sagemcom.com
Tue Jul 19 04:06:58 EDT 2011
hello,
not sure, this is a guess, but you may try to trigger your script at
"TransactionBatch" step instead of "TransactionCreate"
As doing it manually just works fine, it's probably something close to
that.
Raphaël MOUNEYRES
suIIy <bglasson at bytecraft.com.au>
Envoyé par : rt-users-bounces at lists.bestpractical.com
19/07/2011 08:56
A
rt-users at lists.bestpractical.com
cc
Objet
[rt-users] Have a programatically set Custom Field trigger a Condition
Hi All
I'm working on implementing a workflow based queue in RT3.6 based on the
instructions here;
http://requesttracker.wikia.com/wiki/WorkFlow
How it works is this.
A master ticket is created with 3 custom fields. Each custom field can
have
2 values "Required" and "Completed"
When "Required" is set, a scrip creates a child ticket.
When the child ticket is closed, a scrip updates the master ticket and
changes the Custom Field in that ticket from "Required" to "Complete"
Every thing works fine at this point.
I then decided that it would be a neat idea if when the child task is
completed, the next child task could automatically begin.
In theory, to do this would simply require that the "On Resolve" scrip
update the next Custom Field in the workflow, setting it to "Required"
which
should trigger the next child ticket.
After adding a few extra lines to the On Resolve scrip I am now
automatically updating the Custom Field in the next step to "Required",
which should trigger a condition.
This is where I'm stalled.
It seems that the Condition is not triggered when you programmatically set
the Custom Field to "Required". If you unset it and then set it back to
"Required" manually it works just fine.
This is the code for the Condition as per the Workflow wiki page;
8<------------------------------------------------------------------------------------
# Local condition to check that a custom field
# has been set to "Required".
# -Chuck Boeheim 3/13/06
package RT::Condition::FieldRequired;
require RT::Condition::Generic;
use strict;
use vars qw/@ISA/;
@ISA = qw(RT::Condition::Generic);
=head2 IsApplicable
If the field named as an argument becomes 'Required'.
Only triggers on transitions, not if it already had
that value.
=cut
sub IsApplicable {
my $self = shift;
my $field = $self->Argument;
my $trans = $self->TransactionObj;
if ($trans->Type eq 'Create')
{
return 1 if $trans->TicketObj->FirstCustomFieldValue($field) =~
/^Required/;
}
if ($trans->Type eq 'CustomField')
{
my $cf = RT::CustomField->new($self->CurrentUser);
$cf->Load($field);
return 1 if $trans->Field == $cf->Id && $trans->NewValue =~
/^Required/;
}
return undef;
}
1;
8<------------------------------------------------------------------------------------
I reckon the trouble is in this particular script, but I don't really know
perl at all so I could be wrong. I am assuming that I might need another
<code> if ($trans->Type eq '???) </code> block maybe?
If anybody has any ideas on what I need to do to make a programatically
set
custom field trigger a condition I would sure appreciate it.
I don't want to load up this post with tonnes of code so if there is any
extra info you require please let me know.
Thanks in advance.
--
View this message in context:
http://old.nabble.com/Have-a-programatically-set-Custom-Field-trigger-a-Condition-tp32088731p32088731.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
--------
2011 Training: http://bestpractical.com/services/training.html
#
" Ce courriel et les documents qui lui sont joints peuvent contenir des
informations confidentielles ou ayant un caractère privé. S'ils ne vous sont
pas destinés, nous vous signalons qu'il est strictement interdit de les
divulguer, de les reproduire ou d'en utiliser de quelque manière que ce
soit le contenu. Si ce message vous a été transmis par erreur, merci d'en
informer l'expéditeur et de supprimer immédiatement de votre système
informatique ce courriel ainsi que tous les documents qui y sont attachés."
******
" This e-mail and any attached documents may contain confidential or
proprietary information. If you are not the intended recipient, you are
notified that any dissemination, copying of this e-mail and any attachments
thereto or use of their contents by any means whatsoever is strictly
prohibited. If you have received this e-mail in error, please advise the
sender immediately and delete this e-mail and all attached documents
from your computer system."
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110719/5ff6511a/attachment.htm>
More information about the rt-users
mailing list