Extract CF Values on Group restricted CFs

Hi All,

I hope you folks are doing well. I’m going a bit nutso, as I need some advice.

So we have a bunch of CFs available for ticket creation, most getting automagically filled with information extracted from emails etc. Now these CF’s aren’t required to be viewed nor touched by the folks attending the tickets.

What I have done is to set View Custom Fields on the specific CFs themselves which they should be able to view and change, whilst not setting them on the ones which should remain ‘hidden’, and that works perfectly. My only problem comes in when attempting to extract this info in the templates…

For example, we have a bunch of Canned Replies for the agents to select… they look something like this:


Hello, thank you for contacting blah blah

Lots of information

For more information please contact:

{ ### CodeBlock 1 Start

my $address = $Ticket->FirstCustomFieldValue(‘Address’);
my $phone = $Ticket->FirstCustomFieldValue(‘Phone’);
my $email = $Ticket->FirstCustomFieldValue(‘Email’);
my $Address = “false”;
my $Phone = “false”;
my $Email = “false”;

if ($address !~ m/NA/) { $Address = “true”}
else { if($address =~ m/NA/) { $Address = “false”}};

if ($phone !~ m/NA/) { $Phone = “true”}
else { if($phone =~ m/NA/) {$Phone = “false”}};

if ($email !~ m/NA/) {$Email = “true”}
else { if ($email =~ m/NA/) {$Email = “false”}};

if ($Address =~ “true”) { $address;}
elsif ($Address =~ “false” && $Phone =~ “true”) { 'Tel.: ’ . $phone; }
elsif ($Address =~ “false” && $Phone =~ “false” && $Email =~ “true”) { 'eMail: ’ . $email };

CodeBlock End

}

Best regard
Out company info


Now, the above works perfectly (there’s a lot more to the scrip, I only extracted part of it to save on space as it is mostly repeated) for folks who can view ALL of the custom fields, but because the Address, Phone, and Email CFs are hidden from the agents the values in those CFs remain blank once the template is executed.

So, long story short, I wanted to know, if y’all know of a way around this little problem, or if I should just let the folks who requested this option know that those fields have to be viewable by the agents.

I’ve done a fair bit of Googling, but my keywords might be off, as I can’t find a solution.

We’re on RT 4.2.9, if that makes a difference.

Cheers,
Nick

I did a quick read so correct me if I am incorrect, you want the scrip to be able to access those fields regardless of the current users right?

That is correct indeed! No matter their rights, the info will need to be extracted.

Yup that is an easy fix, your ticket object and transaction object (Any RT object for that matter) are loaded in the context of a provided user. For scrips this defaults to the current user, you can do something like this to load a ticket object in the super user context:

my $ticket_super = RT::Ticket->new(RT->SystemUser);
my $ticket_super->Load($self->TicketObj->Id);

Then replace the $self->TicketObj with the $ticket_super object in your scrip where context to the user is not important.

Excellent, thank you. I will give it a go, and report back!

I’ve not had much luck with the system user thus far. It seems to break when I try to pull the values from the CF’s. But I will keep trying.

I can pull the values in scrips, but the templates seem to not like it very much.

How are you attempting to use the system user in the templates? Is there an error you are seeing?