Q about links to deleted tickets

Should links to ticket be deleted when the ticket is deleted?

The reason is ask is, $Ticket->Members->Count may return 1,
but is that members is a deleted ticket then
$Ticket->Members->First returns undef.

Or, should Link::Next give you the link even if it is a link
to a deleted ticket? Why have the link in the database but
not have Next give it tou you???

-Todd

Should links to ticket be deleted when the ticket is deleted?

The reason is ask is, $Ticket->Members->Count may return 1,
but is that members is a deleted ticket then
$Ticket->Members->First returns undef.

Or, should Link::Next give you the link even if it is a link
to a deleted ticket? Why have the link in the database but
not have Next give it tou you???

-Todd

Looking at the code for Link::Next(), it won’t give you
the link if either BaseObj or TargetObj are deleted.
That means you may have asked for the links to a
deleted ticket, and won’t get any of them because of
Next() helpfulness.

Should links to ticket be deleted when the ticket is deleted?

The reason is ask is, $Ticket->Members->Count may return 1,
but is that members is a deleted ticket then
$Ticket->Members->First returns undef.

Or, should Link::Next give you the link even if it is a link
to a deleted ticket? Why have the link in the database but
not have Next give it tou you???

-Todd

OK, I lied a little bit. $Ticket->Members->First gives
you the link. It’s just that $Ticket->Members->Next won’t
give you the link because I tries to be helpful (to
helpful if you ask me).

IMHO, if Next won’t give you a link, then First shouldn’t
either (but I think they both should).

-Todd

Should links to ticket be deleted when the ticket is deleted?

The reason is ask is, $Ticket->Members->Count may return 1,
but is that members is a deleted ticket then
$Ticket->Members->First returns undef.

Or, should Link::Next give you the link even if it is a link
to a deleted ticket? Why have the link in the database but
not have Next give it tou you???

-Todd

OK, I lied a little bit. $Ticket->Members->First gives
you the link. It’s just that $Ticket->Members->Next won’t
give you the link because I tries to be helpful (to
helpful if you ask me).

IMHO, if Next won’t give you a link, then First shouldn’t
either (but I think they both should).

Nobody has an opinion???

Should links to ticket be deleted when the ticket is deleted?

The reason is ask is, $Ticket->Members->Count may return 1,
but is that members is a deleted ticket then
$Ticket->Members->First returns undef.

Or, should Link::Next give you the link even if it is a link
to a deleted ticket? Why have the link in the database but
not have Next give it tou you???

-Todd

OK, I lied a little bit. $Ticket->Members->First gives
you the link. It’s just that $Ticket->Members->Next won’t
give you the link because I tries to be helpful (to
helpful if you ask me).

IMHO, if Next won’t give you a link, then First shouldn’t
either (but I think they both should).

Nobody has an opinion???
We have :slight_smile: I agree that both methods MUST have the same behaviour, but
don’t know which one. I don’t like all this deep in core hidding of
the objects even they were marked as deleted, I think that it’s too
restrictive and also force me to write patchs and bundle shredder with
them :stuck_out_tongue:

Looks like I must look into shredder and check it for bugs related to
this code :frowning:


List info: The rt-devel Archives

Best Practical is hiring! Come hack Perl for us: Careers — Best Practical Solutions

Best regards, Ruslan.

Should links to ticket be deleted when the ticket is deleted?

The reason is ask is, $Ticket->Members->Count may return 1,
but is that members is a deleted ticket then
$Ticket->Members->First returns undef.

Or, should Link::Next give you the link even if it is a link
to a deleted ticket? Why have the link in the database but
not have Next give it tou you???

-Todd

OK, I lied a little bit. $Ticket->Members->First gives
you the link. It’s just that $Ticket->Members->Next won’t
give you the link because I tries to be helpful (to> > helpful if you ask me).

IMHO, if Next won’t give you a link, then First shouldn’t
either (but I think they both should).

Nobody has an opinion???

We have :slight_smile: I agree that both methods MUST have the same behaviour, butdon’t know which one. I don’t like all this deep in core hidding ofthe objects even they were marked as deleted, I think that it’s toorestrictive and also force me to write patchs and bundle shredder withthem :stuck_out_tongue:

Looks like I must look into shredder and check it for bugs related tothis code :frowning:

If Jesse would give an opion I could submit a patch… :wink:

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

Don�t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

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:

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@vitamix.com
To: Jared Hanks jmhanks1373@hotmail.com
CC: rt-users@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


Don�t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


The rt-users Archives

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

We’re hiring! Come hack Perl for Best Practical:
Careers — Best Practical Solutions

Don�t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/