REST interface, getting custom fields

Hi,

I’m using the perl module ‘RT::Client::REST’ to query the database for tickets with a specific custom field with a value and update the tickets to a different owner and state.

Script works for 2 other queues without issue. The 3rd queue however, configured the same as far as I can see, behaves differently.

The script does a search and finds tickets that meet the criteria (CF.{Mingle Card Number} > 0), which says to me that the tickets have the custom field visible to the user I’m logged in as. Cool.

I then loop through the search results getting the individual ticket details (to get the value of the custom field):

    my $ticket = RT::Client::REST::Ticket->new(
            rt => $_RT,
            id => $id,
    )->retrieve;
    if (!defined($ticket->cf($_cf_name))) {
            print Dumper($ticket->{'__cf'});
            printf(STDERR "Unable to find the %s on ticket %d\n", $_cf_name, $id);
            next;
    }

This fails on the one queue.

Example of the failure:

$VAR1 = {
‘(sc/fr) clarifications’ => ‘N/A’,
‘(sc/fr) summary’ => ‘For one thing it will make reports that are no longer downloadable accessible.’,
‘(sc/fr) scope’ => ‘Reporting components of the *********** website.’,
‘user priority’ => ‘’,
‘psm monitor’ => ‘’,
‘dev priority’ => ‘2 - Needs looking at within a week or so’,
‘(sc/fr) context’ => ‘Line limit is no longer required.’
};
Unable to find the Mingle Card Number on ticket 7152

I’ve gone over the permissions on the queue a few times, left it for a few hours and reviewed them again. I can’t figure out why this works for the other queues and not this one.

No errors are logged at debug level. A restart of the apache instance doesn’t resolve the issue.

User ID: 11098, member of:
Group ID: 147279 (Principals id: 147279)
Queue ID: 31
CF ID: 49

Confirmed the CF is allocated to the queue with the name ‘Mingle Card Number’ (‘select * from ObjectCustomFields where CustomField = 49 and ObjectId = 31’ and ‘select Name from CustomFields where id = 49’) and that there is only one Custom Field with this name.

Group has the following permissions on the queue (confirmed by ’ select * from ACL where ObjectId = 31 and PrincipalId = 147279’):
ModifyCustomField
ModifyTicket
OwnTicket
SeeCustomField

Where should I be checking next?

RT 3.8.8, RT::Client::REST 0.40, RedHat, MySQL.

Stuart J. Browne
Senior Unix Administrator, Network Administrator
AusRegistry Pty Ltd
Level 8, 10 Queens Road
Melbourne. Victoria. Australia. 3004.
Ph: +61 3 9866 3710
Fax: +61 3 9866 1970
Email: stuart.browne@ausregistry.com.au
Web: www.ausregistry.com.au

The information contained in this communication is intended for the named recipients only. It is subject to copyright and may contain legally privileged and confidential information and if you are not an intended recipient you must not use, copy, distribute or take any action in reliance on it. If you have received this communication in error, please delete all copies from your system and notify us immediately.

-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-
bounces@lists.bestpractical.com] On Behalf Of Stuart Browne
Sent: Tuesday, 30 August 2011 5:09 PM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] REST interface, getting custom fields

Hi,

I’m using the perl module ‘RT::Client::REST’ to query the database for
tickets with a specific custom field with a value and update the tickets
to a different owner and state.

Script works for 2 other queues without issue. The 3rd queue however,
configured the same as far as I can see, behaves differently.

Sadly, I’ve confirmed this is a bug in the RT::Client::REST interface (also in 0.41). Using RT’s ‘/opt/rt3/bin/rt’ does correctly retrieve all the custom fields.

Time for debug.

Stuart

Hi,

I’m using the perl module ‘RT::Client::REST’ to query the database for
tickets with a specific custom field with a value and update the tickets
to a different owner and state.

Script works for 2 other queues without issue. The 3rd queue however,
configured the same as far as I can see, behaves differently.

Sadly, I’ve confirmed this is a bug in the RT::Client::REST interface
(also in 0.41). Using RT’s ‘/opt/rt3/bin/rt’ does correctly retrieve all
the custom fields.

Time for debug.

Debug has found the following (in both /opt/rt3/bin/rt and RT::Client::REST::Forms and RT::Client::REST::Object):

* $CF_name defines the list of valid characters in a custom field name.  The field before my missing custom field had a question-mark in it (?).  This caused the field matching in the form parse routine to fail.
* The RT::Client::REST::Object did further parsing to break down the attributes into a __cf hash.  It re-parsed the custom field names.  Same deal, question-mark.

Sending a patch through to the CPAN. Single-character addition :wink:

Stuart