[rt-users] Setting Custom Fields upon autocreation of ticket
Jared Hanks
jmhanks1373 at hotmail.com
Wed Apr 5 17:28:32 EDT 2006
I was able to get it to work using the following:
if($self->TicketObj->Subject =~/TemporaryAccess/i)
{
my $TicketObjItem = RT::Ticket->new(RT::CurrentUser->new($RT::SystemUser));
my $TicketId = $TicketObjItem->Create(Queue => $count, Type => "Ticket",
Subject => "Delete Temporary Login", RefersTo => $self->TicketObj->Id);
$TicketObjItem->AddCustomFieldValue( Field => '37', Value => "Access",
RecordTransaction => 1 );
unless( $status )
{
$RT::Logger->warning( "Couldn't set Access as value for CF TicketType". $msg
);
return undef;
}
$TicketObjItem->AddCustomFieldValue( Field => '38', Value => "Separation",
RecordTransaction => 1 );
unless( $status )
{
$RT::Logger->warning( "Couldn't set Separation as value for CF
AccessManagementType". $msg );
return undef;
}
}
Thanks for the help.
Jared
>From: Jason Fenner <jfenner at vitamix.com>
>To: Jared Hanks <jmhanks1373 at hotmail.com>
>CC: rt-users at lists.bestpractical.com
>Subject: Re: [rt-users] Setting Custom Fields upon autocreation of ticket
>Date: Wed, 05 Apr 2006 15:54:02 -0400
>
>Jared, I just solved that same puzzle myself. Take a look at this snippet
>and see if it helps you out:
>
>unless( $self->TicketObj->FirstCustomFieldValue( '2' ) ) {
>my( $st, $msg ) = $self->TicketObj->AddCustomFieldValue(
>Field => '2',
>Value => $DefaultValue,
>RecordTransaction => $RecTransaction );
>unless( $st ) {
>$RT::Logger->warning( "Couldn't set $DefaultValue as value for CF :". $msg
>);
>
>--Jason
>
>Jared Hanks wrote:
>
>>Hello,
>>
>>When a ticket is created via Email with TemporaryAccess in the subject the
>>following scrip runs to create 2 tickets. The second ticket is created and
>>refers to the first ticket.
>>
>>if($self->TicketObj->Subject =~/TemporaryAccess/i)
>>{
>>my $TicketObjItem =
>>RT::Ticket->new(RT::CurrentUser->new($RT::SystemUser));
>>my $TicketId = $TicketObjItem->Create(Queue => $count, Type => "Ticket",
>>Subject => "Delete Temporary Login", RefersTo => $self->TicketObj->Id);
>>}
>>
>>This is working fine, but I would like set some custom fields in the
>>second ticket. How do I go about this? The custom field ID's of the custom
>>fields I need to set are 37 and 38 and are named TicketType and
>>AccessManagementType. The custom field value ID's are 116 and 119 and are
>>named Access and Separation.
>>
>>I have tried to use CustomField37 => "Access", CustomField38 =>
>>"Separation", and CustomField37 => 116, CustomField38 => 119, but neither
>>has worked. I think this can be done but am just unsure of how to
>>accomplish this.
>>
>>Any help would be greatly appreciated.
>>
>>Thanks,
>>Jared
>>
>>_________________________________________________________________
>>Dont just search. Find. Check out the new MSN Search!
>>http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>>
>>_______________________________________________
>>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
>>
>>
>>We're hiring! Come hack Perl for Best Practical:
>>http://bestpractical.com/about/jobs.html
>>
>
>
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
More information about the rt-users
mailing list