[rt-users] Scrip and custom field Help
Potla, Ashish Bassaliel
c_apotla at qualcomm.com
Mon Mar 9 15:31:00 EDT 2009
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;
-Ashish
________________________________________
From: Chris Newcomb [chris at eaglehawkonline.com]
Sent: Monday, March 09, 2009 10:21 PM
To: Potla, Ashish Bassaliel
Subject: Re: [rt-users] Scrip and custom field Help
Correct,
On resolving
if TicketStatus == Created[orbit] or Updated[Orbit] change set TicketStatus = Closed [Orbit]
--
Regards
Chris Newcomb
Potla, Ashish Bassaliel wrote:
> So the jist is On resolving ,
> if TicketStatus == Created[orbit] or Updated[Orbit] , the value of TicketStatus should be set to Closed [Orbit]
>
> For anyother value of TicketStatus the value should be unchanged.
>
> Am I getting this right?
>
> -Ashish
> ________________________________________
> From: Chris Newcomb [chris at eaglehawkonline.com]
> Sent: Monday, March 09, 2009 9:22 PM
> To: Potla, Ashish Bassaliel
> Subject: Re: [rt-users] Scrip and custom field Help
>
> In this CF there are the following values:
>
> Created [Orbit] - if this status when resolved needs to be Closed [Orbit].
> Updated [Orbit] - if this status when resolved needs it needs to be
> Closed [Orbit].
> Closed [Orbit]
> Non-Compliance [email] - never touches Created [Orbit] and never needs
> to be Closed [Orbit]
> Retraction [email] - never touches Created [Orbit] and never needs to be
> Closed [Orbit]
> non-network [email] - never touches Created [Orbit] and never needs to
> be Closed [Orbit]
>
> (I didn't setup this installation of rt)
> --
> Regards,
> Chris Newcomb
>
>
> Potla, Ashish Bassaliel wrote:
>
>> I am a bit confused here. Let me see if I got this correct :
>>
>> On resolve, you want to set the custom field 'TicketStatus' to 'Closed[Orbit]' .. correct? In that case the scrip I gave should be sufficient. Why do the other states of the CF come into picture?
>>
>> -Ashish
>> ________________________________________
>> From: Chris Newcomb [chris at eaglehawkonline.com]
>> Sent: Friday, March 06, 2009 1:59 AM
>> To: Potla, Ashish Bassaliel
>> Subject: Re: [rt-users] Scrip and custom field Help
>>
>> Thanks for your help. I didn't think about the condition needing to
>> check if it was on resolve and the ticket status is either Created
>> [Orbit] or Updated [Orbit]. Any suggestions on what to try here?
>>
>> --
>> Regards
>> Chris
>>
>> Potla, Ashish Bassaliel wrote:
>>
>>
>>> 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;
>>>
>>> -Ashish
>>> ________________________________________
>>> From: rt-users-bounces at lists.bestpractical.com [rt-users-bounces at lists.bestpractical.com] On Behalf Of Chris Newcomb [chris at eaglehawkonline.com]
>>> Sent: Thursday, March 05, 2009 9:42 PM
>>> To: rt-users at 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 at bestpractical.com
>>>
>>>
>>> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
>>> Buy a copy at http://rtbook.bestpractical.com
>>>
>>>
>>>
>>>
>>
>>
>
>
>
More information about the rt-users
mailing list