Asset Tracker: add link to asset from Ticket custom field

Everyone,

I apologize for posting this on the RT list, but I can not find even an
archive of the old AT list, and I’m sure I’ve seen the answer to my
question there.

Basically, I want to be able to link a ticket to an asset by putting the
assets id in a custom field for the ticket. I recall that it was quite
simple. You needed to put in a value in the “Link values to” for the
tickets custom field, I just don’t recall for the format was.

Thanks for the help,

Craig Patterson
Application Developer/SDE Administrator
Northrop Grumman IT/City of Grand Rapids
(616)456-3645
crpatter@grcity.us

In the “refers to” field of the ticket, put ‘at://potsdam.edu/asset/66’
where ‘potsdam.edu’ is the name of the RT domain, and ‘66’ is the number
of the ticket.On Fri, 2007-10-12 at 10:57 -0400, Patterson, Craig wrote:

Everyone,

I apologize for posting this on the RT list, but I can not find even an
archive of the old AT list, and I’m sure I’ve seen the answer to my
question there.

Basically, I want to be able to link a ticket to an asset by putting the
assets id in a custom field for the ticket. I recall that it was quite
simple. You needed to put in a value in the “Link values to” for the
tickets custom field, I just don’t recall for the format was.

Thanks Matthew and Gabrielle,

What I was trying to do was a little more complex, I probably didn’t
explain it very well. I wanted make the asset a “refers to” link from
the ticket’s links page. Luckily I finally found the solution in our
old development DB. The solution required a scrip which I found on the
old asset tracker list ages ago…

Custom Condition:
my $trans = $self->TransactionObj->Type;
my $new_value = $self->TransactionObj->NewValue;
my $cf_id = $self->TransactionObj->Field;

if ($trans ne ‘CustomField’) { return 0; }
if (! $new_value) { return 0; }
my $cf = new RT::CustomField($RT::SystemUser);
my ($id,$msg) = $cf->Load($cf_id);

if (!$id) {
$RT::Logger->crit(“Could not load CF: $msg”);
return 0;
}
if ($cf->Name ne ‘asset’) { return 0; }

1;

Custom action preparation code:
1;

Custom action cleanup code:
my $new_value = $self->TransactionObj->NewValue;
my $asset = RTx::AssetTracker::Asset->new($self->CurrentUser);
my ($id,$msg) = $asset->Load($new_value);
if (! $id) {
$RT::Logger->crit(“Could not load asset $new_value: $msg”);
return 0;
}
($id,$msg) = $self->TicketObj->AddLink(Type => ‘RefersTo’, Target =>
$asset->URI);
if (! $id) {
$RT::Logger->crit(“Could not AddLink: $msg”);
return 0;
}
1;

So now I can type in the name of the asset on in Tickets custom field
and automatically link it to the asset. What is the benefit? We don’t
have to change our ticket creation process for regular user requests,
ie, from the phone or from email. Plus, we can look at the asset and
see all of the tickets associated to it in the “Referred to by” area.

CraigFrom: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Monday, October 15, 2007 10:01 AM
To: Patterson, Craig
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Asset Tracker: add link to asset from Ticket
customfield

In the “refers to” field of the ticket, put ‘at://potsdam.edu/asset/66’
where ‘potsdam.edu’ is the name of the RT domain, and ‘66’ is the number
of the ticket.

Everyone,

I apologize for posting this on the RT list, but I can not find even
an
archive of the old AT list, and I’m sure I’ve seen the answer to my
question there.

Basically, I want to be able to link a ticket to an asset by putting
the
assets id in a custom field for the ticket. I recall that it was
quite
simple. You needed to put in a value in the “Link values to” for the
tickets custom field, I just don’t recall for the format was.

What I explained is exactly the same thing, without the need for a
custom field.On Tue, 2007-10-16 at 09:33 -0400, Patterson, Craig wrote:

Thanks Matthew and Gabrielle,

What I was trying to do was a little more complex, I probably didn’t
explain it very well. I wanted make the asset a “refers to” link from
the ticket’s links page. Luckily I finally found the solution in our
old development DB. The solution required a scrip which I found on the
old asset tracker list ages ago…

Custom Condition:
my $trans = $self->TransactionObj->Type;
my $new_value = $self->TransactionObj->NewValue;
my $cf_id = $self->TransactionObj->Field;

if ($trans ne ‘CustomField’) { return 0; }
if (! $new_value) { return 0; }
my $cf = new RT::CustomField($RT::SystemUser);
my ($id,$msg) = $cf->Load($cf_id);

if (!$id) {
$RT::Logger->crit(“Could not load CF: $msg”);
return 0;
}
if ($cf->Name ne ‘asset’) { return 0; }

1;

Custom action preparation code:
1;

Custom action cleanup code:
my $new_value = $self->TransactionObj->NewValue;
my $asset = RTx::AssetTracker::Asset->new($self->CurrentUser);
my ($id,$msg) = $asset->Load($new_value);
if (! $id) {
$RT::Logger->crit(“Could not load asset $new_value: $msg”);
return 0;
}
($id,$msg) = $self->TicketObj->AddLink(Type => ‘RefersTo’, Target =>
$asset->URI);
if (! $id) {
$RT::Logger->crit(“Could not AddLink: $msg”);
return 0;
}
1;

So now I can type in the name of the asset on in Tickets custom field
and automatically link it to the asset. What is the benefit? We don’t
have to change our ticket creation process for regular user requests,
ie, from the phone or from email. Plus, we can look at the asset and
see all of the tickets associated to it in the “Referred to by” area.

Craig

-----Original Message-----
From: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Monday, October 15, 2007 10:01 AM
To: Patterson, Craig
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Asset Tracker: add link to asset from Ticket
customfield

In the “refers to” field of the ticket, put ‘at://potsdam.edu/asset/66’
where ‘potsdam.edu’ is the name of the RT domain, and ‘66’ is the number
of the ticket.

On Fri, 2007-10-12 at 10:57 -0400, Patterson, Craig wrote:

Everyone,

I apologize for posting this on the RT list, but I can not find even
an
archive of the old AT list, and I’m sure I’ve seen the answer to my
question there.

Basically, I want to be able to link a ticket to an asset by putting
the
assets id in a custom field for the ticket. I recall that it was
quite
simple. You needed to put in a value in the “Link values to” for the
tickets custom field, I just don’t recall for the format was.

Matthew,

I was trying your method without success. If I use put
at://[mywebpath]/asset/[assetid] in the “refers to” link, it returns
Couldn’t resolve ‘at://testhelpdesk/rt/asset/1’ into a URI.

If I change “at” to “http”, RT accepts it, but it really is just a hyper
link. If I go to the asset page and look at “referred to by” is blank,
and if I click the link itself from the ticket screen, it opens up a new
window and I get a not found error.

Is there some step I’m missing?

Thanks for any suggestions,

CraigFrom: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Tuesday, October 16, 2007 9:39 AM
To: Patterson, Craig
Cc: Franzini, Gabriele [Nervianoms]; rt-users@lists.bestpractical.com
Subject: RE: [rt-users] Asset Tracker: add link to asset from
Ticketcustomfield

What I explained is exactly the same thing, without the need for a
custom field.

Thanks Matthew and Gabrielle,

What I was trying to do was a little more complex, I probably didn’t
explain it very well. I wanted make the asset a “refers to” link from
the ticket’s links page. Luckily I finally found the solution in our
old development DB. The solution required a scrip which I found on
the
old asset tracker list ages ago…

Custom Condition:
my $trans = $self->TransactionObj->Type;
my $new_value = $self->TransactionObj->NewValue;
my $cf_id = $self->TransactionObj->Field;

if ($trans ne ‘CustomField’) { return 0; }
if (! $new_value) { return 0; }
my $cf = new RT::CustomField($RT::SystemUser);
my ($id,$msg) = $cf->Load($cf_id);

if (!$id) {
$RT::Logger->crit(“Could not load CF: $msg”);
return 0;
}
if ($cf->Name ne ‘asset’) { return 0; }

1;

Custom action preparation code:
1;

Custom action cleanup code:
my $new_value = $self->TransactionObj->NewValue;
my $asset = RTx::AssetTracker::Asset->new($self->CurrentUser);
my ($id,$msg) = $asset->Load($new_value);
if (! $id) {
$RT::Logger->crit(“Could not load asset $new_value: $msg”);
return 0;
}
($id,$msg) = $self->TicketObj->AddLink(Type => ‘RefersTo’, Target =>
$asset->URI);
if (! $id) {
$RT::Logger->crit(“Could not AddLink: $msg”);
return 0;
}
1;

So now I can type in the name of the asset on in Tickets custom field
and automatically link it to the asset. What is the benefit? We
don’t
have to change our ticket creation process for regular user requests,
ie, from the phone or from email. Plus, we can look at the asset and
see all of the tickets associated to it in the “Referred to by” area.

Craig

-----Original Message-----
From: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Monday, October 15, 2007 10:01 AM
To: Patterson, Craig
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Asset Tracker: add link to asset from Ticket
customfield

In the “refers to” field of the ticket, put
‘at://potsdam.edu/asset/66’
where ‘potsdam.edu’ is the name of the RT domain, and ‘66’ is the
number
of the ticket.

Everyone,

I apologize for posting this on the RT list, but I can not find even
an
archive of the old AT list, and I’m sure I’ve seen the answer to my
question there.

Basically, I want to be able to link a ticket to an asset by putting
the
assets id in a custom field for the ticket. I recall that it was
quite
simple. You needed to put in a value in the “Link values to” for
the
tickets custom field, I just don’t recall for the format was.

look in RT_SiteConfig.pm for what ‘$rtname’ is set to - this is what you
should put in what you have marked as [mywebpath].

eg. Set( $rtname, ‘potsdam.edu’);On Tue, 2007-10-16 at 13:16 -0400, Patterson, Craig wrote:

Matthew,

I was trying your method without success. If I use put
at://[mywebpath]/asset/[assetid] in the “refers to” link, it returns
Couldn’t resolve ‘at://testhelpdesk/rt/asset/1’ into a URI.

If I change “at” to “http”, RT accepts it, but it really is just a hyper
link. If I go to the asset page and look at “referred to by” is blank,
and if I click the link itself from the ticket screen, it opens up a new
window and I get a not found error.

Is there some step I’m missing?

Thanks for any suggestions,

Craig

-----Original Message-----
From: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Tuesday, October 16, 2007 9:39 AM
To: Patterson, Craig
Cc: Franzini, Gabriele [Nervianoms]; rt-users@lists.bestpractical.com
Subject: RE: [rt-users] Asset Tracker: add link to asset from
Ticketcustomfield

What I explained is exactly the same thing, without the need for a
custom field.

On Tue, 2007-10-16 at 09:33 -0400, Patterson, Craig wrote:

Thanks Matthew and Gabrielle,

What I was trying to do was a little more complex, I probably didn’t
explain it very well. I wanted make the asset a “refers to” link from
the ticket’s links page. Luckily I finally found the solution in our
old development DB. The solution required a scrip which I found on
the
old asset tracker list ages ago…

Custom Condition:
my $trans = $self->TransactionObj->Type;
my $new_value = $self->TransactionObj->NewValue;
my $cf_id = $self->TransactionObj->Field;

if ($trans ne ‘CustomField’) { return 0; }
if (! $new_value) { return 0; }
my $cf = new RT::CustomField($RT::SystemUser);
my ($id,$msg) = $cf->Load($cf_id);

if (!$id) {
$RT::Logger->crit(“Could not load CF: $msg”);
return 0;
}
if ($cf->Name ne ‘asset’) { return 0; }

1;

Custom action preparation code:
1;

Custom action cleanup code:
my $new_value = $self->TransactionObj->NewValue;
my $asset = RTx::AssetTracker::Asset->new($self->CurrentUser);
my ($id,$msg) = $asset->Load($new_value);
if (! $id) {
$RT::Logger->crit(“Could not load asset $new_value: $msg”);
return 0;
}
($id,$msg) = $self->TicketObj->AddLink(Type => ‘RefersTo’, Target =>
$asset->URI);
if (! $id) {
$RT::Logger->crit(“Could not AddLink: $msg”);
return 0;
}
1;

So now I can type in the name of the asset on in Tickets custom field
and automatically link it to the asset. What is the benefit? We
don’t
have to change our ticket creation process for regular user requests,
ie, from the phone or from email. Plus, we can look at the asset and
see all of the tickets associated to it in the “Referred to by” area.

Craig

-----Original Message-----
From: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Monday, October 15, 2007 10:01 AM
To: Patterson, Craig
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Asset Tracker: add link to asset from Ticket
customfield

In the “refers to” field of the ticket, put
‘at://potsdam.edu/asset/66’
where ‘potsdam.edu’ is the name of the RT domain, and ‘66’ is the
number
of the ticket.

On Fri, 2007-10-12 at 10:57 -0400, Patterson, Craig wrote:

Everyone,

I apologize for posting this on the RT list, but I can not find even
an
archive of the old AT list, and I’m sure I’ve seen the answer to my
question there.

Basically, I want to be able to link a ticket to an asset by putting
the
assets id in a custom field for the ticket. I recall that it was
quite
simple. You needed to put in a value in the “Link values to” for
the
tickets custom field, I just don’t recall for the format was.

Actually, it was the $Organization that needed to be changed. I hadn’t
changed mine from default and it was looking for
“at://example.com/asset/1”

My system is in production and I’m afraid if I change it as this point,
I’m going to mess up all of my existing links. I may have to live with
it unless there is a way to update my existing links.

Thanks for the insight,

CraigFrom: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Tuesday, October 16, 2007 1:35 PM
To: Patterson, Craig
Cc: Franzini, Gabriele [Nervianoms]; rt-users@lists.bestpractical.com
Subject: RE: [rt-users] Asset Tracker: add link to asset
fromTicketcustomfield

look in RT_SiteConfig.pm for what ‘$rtname’ is set to - this is what you
should put in what you have marked as [mywebpath].

eg. Set( $rtname, ‘potsdam.edu’);

Matthew,

I was trying your method without success. If I use put
at://[mywebpath]/asset/[assetid] in the “refers to” link, it returns
Couldn’t resolve ‘at://testhelpdesk/rt/asset/1’ into a URI.

If I change “at” to “http”, RT accepts it, but it really is just a
hyper
link. If I go to the asset page and look at “referred to by” is
blank,
and if I click the link itself from the ticket screen, it opens up a
new
window and I get a not found error.

Is there some step I’m missing?

Thanks for any suggestions,

Craig

-----Original Message-----
From: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Tuesday, October 16, 2007 9:39 AM
To: Patterson, Craig
Cc: Franzini, Gabriele [Nervianoms]; rt-users@lists.bestpractical.com
Subject: RE: [rt-users] Asset Tracker: add link to asset from
Ticketcustomfield

What I explained is exactly the same thing, without the need for a
custom field.

Thanks Matthew and Gabrielle,

What I was trying to do was a little more complex, I probably didn’t
explain it very well. I wanted make the asset a “refers to” link
from
the ticket’s links page. Luckily I finally found the solution in
our
old development DB. The solution required a scrip which I found on
the
old asset tracker list ages ago…

Custom Condition:
my $trans = $self->TransactionObj->Type;
my $new_value = $self->TransactionObj->NewValue;
my $cf_id = $self->TransactionObj->Field;

if ($trans ne ‘CustomField’) { return 0; }
if (! $new_value) { return 0; }
my $cf = new RT::CustomField($RT::SystemUser);
my ($id,$msg) = $cf->Load($cf_id);

if (!$id) {
$RT::Logger->crit(“Could not load CF: $msg”);
return 0;
}
if ($cf->Name ne ‘asset’) { return 0; }

1;

Custom action preparation code:
1;

Custom action cleanup code:
my $new_value = $self->TransactionObj->NewValue;
my $asset = RTx::AssetTracker::Asset->new($self->CurrentUser);
my ($id,$msg) = $asset->Load($new_value);
if (! $id) {
$RT::Logger->crit(“Could not load asset $new_value: $msg”);
return 0;
}
($id,$msg) = $self->TicketObj->AddLink(Type => ‘RefersTo’, Target =>
$asset->URI);
if (! $id) {
$RT::Logger->crit(“Could not AddLink: $msg”);
return 0;
}
1;

So now I can type in the name of the asset on in Tickets custom
field
and automatically link it to the asset. What is the benefit? We
don’t
have to change our ticket creation process for regular user
requests,
ie, from the phone or from email. Plus, we can look at the asset
and
see all of the tickets associated to it in the “Referred to by”
area.

Craig

-----Original Message-----
From: Matthew Keller [mailto:kellermg@potsdam.edu]
Sent: Monday, October 15, 2007 10:01 AM
To: Patterson, Craig
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Asset Tracker: add link to asset from Ticket
customfield

In the “refers to” field of the ticket, put
‘at://potsdam.edu/asset/66’
where ‘potsdam.edu’ is the name of the RT domain, and ‘66’ is the
number
of the ticket.

Everyone,

I apologize for posting this on the RT list, but I can not find
even
an
archive of the old AT list, and I’m sure I’ve seen the answer to
my
question there.

Basically, I want to be able to link a ticket to an asset by
putting
the
assets id in a custom field for the ticket. I recall that it was
quite
simple. You needed to put in a value in the “Link values to” for
the
tickets custom field, I just don’t recall for the format was.

Patterson, Craig wrote:

Actually, it was the $Organization that needed to be changed. I hadn’t
changed mine from default and it was looking for
“at://example.com/asset/1”

My system is in production and I’m afraid if I change it as this point,
I’m going to mess up all of my existing links. I may have to live with
it unless there is a way to update my existing links.

There is but first a word of warning. Do try this on a test db !!!
All you need to do is update the Links table with the correct
information, changing all at://example.com/asset/ rows to the correct
at://$Organisation/asset/
There is also information in the Transactions table concerning links but
it looks like it is historical information. You could opt to change
this as well.

I have done this once for a production system where there was a name
change and haven’t had a problem since so I think it is safe to do,
YMMV, do be careful to test this on a test DB first!!

Good luck,

Joop