Scrip and custom field Help

I’ve googled and either my google fu is not working or I’m not finding
the correct answer, and I barely know perl.

Using RT 3.8.1 on freebsd using mysql

Condition: On Resolve

Action: is where I need help.

I have a custom field named TicketStatus. I want to on resolve set the
custom field to be “Closed [Orbit]”, usually the ticket status is either
Created [Orbit] or Updated [Orbit].

any pointers that you can give me would be great, either by telling me
what to search for or giving me an idea of what to use to get the action
done.

Thanks in advance
Chris Newcomb

Hi Chris,
Try this:

Condition : On resolve

Custom Action Preparation Code :

set the CF Work-Completed Date

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $cf_obj = RT::CustomField->new($RT::SystemUser);
my $cf_name = “TicketStatus”;
my $cf_value = “Closed [Orbit]”;

$cf_obj->LoadByName(Name=>$cf_name);
$RT::Logger->debug(“Loaded$cf_obj->Name = “. $cf_obj->Name() .”\n”);
$ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$cf_value,
RecordTransaction=>0);
return 1;

Custom cleanup code :
return 1;

-AshishFrom: rt-users-bounces@lists.bestpractical.com [rt-users-bounces@lists.bestpractical.com] On Behalf Of Chris Newcomb [chris@eaglehawkonline.com]
Sent: Thursday, March 05, 2009 9:42 PM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Scrip and custom field Help

I’ve googled and either my google fu is not working or I’m not finding
the correct answer, and I barely know perl.

Using RT 3.8.1 on freebsd using mysql

Condition: On Resolve

Action: is where I need help.

I have a custom field named TicketStatus. I want to on resolve set the
custom field to be “Closed [Orbit]”, usually the ticket status is either
Created [Orbit] or Updated [Orbit].

any pointers that you can give me would be great, either by telling me
what to search for or giving me an idea of what to use to get the action
done.

Thanks in advance
Chris Newcomb

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Chris,

Why in the world do you have a Custom Field named the same as a RT 

Ticket field? To me, that would create a bit of confusion when someone
would discuss the values in the two fields. I wouldn’t know which one
they are talking about, the Custom Field or the Ticket field. Also, if
the RT Ticket Status field says resolved, then the ticket IS closed and
any other iteration would be redundant. We have a Custom Field called
"Work-State" which allows for more granularity when IN a particular
status. For example, the TIcket Status may be “open”, but the work is
"On Hold" or “In progress” or “Unit Testing”, etc. That way, we have a
Ticket Status telling us what is going on with the “Ticket” and a
Custom Field telling what step the actual “work” is on. Just a thought.

Kenn
LBNLOn 3/5/2009 8:12 AM, Chris Newcomb wrote:

I’ve googled and either my google fu is not working or I’m not finding
the correct answer, and I barely know perl.

Using RT 3.8.1 on freebsd using mysql

Condition: On Resolve

Action: is where I need help.

I have a custom field named TicketStatus. I want to on resolve set the
custom field to be “Closed [Orbit]”, usually the ticket status is either
Created [Orbit] or Updated [Orbit].

any pointers that you can give me would be great, either by telling me
what to search for or giving me an idea of what to use to get the action
done.


Thanks in advance
Chris Newcomb


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi,
Try this in the prep code and test it out :

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

my $cf_obj = RT::CustomField->new($RT::SystemUser);
my $queue = RT::Queue->new($RT::SystemUser);
my $OCFvs = new RT::ObjectCustomFieldValues($RT::SystemUser);
my $createrObj = RT::User->new($RT::SystemUser);

$createrObj = $self->TransactionObj->CreatorObj;

my $cf_name = “ticketstatus”;
my $cf_value = “Closed [Orbit]”;

$queue->Load($self->TicketObj->QueueObj->Name);
$OCFvs->LimitToObject($self->TicketObj);

while (my $OCFv = $OCFvs->Next()) {
$cf_obj = $OCFv->CustomFieldObj;
if (lc $cf_obj->Name eq $cf_name) {
if ($self->TicketObj->Status eq ‘resolved’ and $queue->HasRight(Right => ‘ModifyTicket’,Principal => $createrObj)) {
$ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$cf_value, RecordTransaction=>0) if ($OCFv->Content eq ‘Created [Orbit]’ or $OCFv->Content eq ‘Updated [Orbit]’) ;
}
}
}
return 1;

-AshishFrom: Chris Newcomb [chris@eaglehawkonline.com]
Sent: Monday, March 09, 2009 10:21 PM
To: Potla, Ashish Bassaliel
Subject: Re: [rt-users] Scrip and custom field Help

Correct,