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.