CommandByMail and Custom Fields

I have CommandByMail working correctly on a new 3.6.1 install for all
standard fields. However, I am unable to get it to correctly work with
Custom Fields. I’m hoping someone will spot the error I’ve obviously
missed as there’s nothing on the wiki or mailing list that indicates
this functionality is not working for others.

I have a Custom Field called ‘site’ that is type ‘Select One Value’. If
I send the following line in an e-m ail to rt:

CustomField.{site}: EAS

it does not set the field. I’ve added some additional logging to try to
figure out what’s going on in TakeAction.pm. I’ve found that it does run
the _CanonicalizeCommand function and changes the key to
’customfield{site}’. It does not appear to trigger the following chunk
of code however:

Canonicalize custom fields

    my $custom_fields = $queue->TicketCustomFields;
    while ( my $cf = $custom_fields->Next ) {
        my %tmp = _ParseAdditiveCommand( \%cmds, 0, "CustomField{". 

$cf->Name ."}" );
next unless keys %tmp;
$RT::Logger->warning( “Canonicalize custom fields” );
$create_args{ ‘CustomField-’ . $cf->id } = [
_CompileAdditiveForCreate(%tmp) ];
}

That is, my additional Logger line never gets triggered and it seems
that it should.

Any thoughts on what to look for would be greatly appreciated!

Chris

I have a Custom Field called ‘site’ that is type ‘Select One Value’.
If I send the following line in an e-m ail to rt:

I have exactly the same problem (except I’m on RT 3.4.5). A custom
field of type ‘Select One Value’ that I can’t seem to select via
CommandByMail.

Can anyone shed any light on this?

Thanks,
Keith

I’ve done a bit more research on this, and to keep it simple I created
an “Enter one value” custom field called ‘Textline’.

I added some debug lines to TakeAction.pm as follows (my lines marked
“>>>”):

    # Canonicalize custom fields
$RT::Logger->warning("X1");
    my $custom_fields = $queue->TicketCustomFields;
    while ( my $cf = $custom_fields->Next ) {
    $RT::Logger->warning("X2: cf=$cf");
        my %tmp = _ParseAdditiveCommand( \%cmds, 0, "CustomField{".

$cf->Name .“}” ); next unless keys %tmp;
$create_args{ ‘CustomField-’ . $cf->id } =
[ _CompileAdditiveForCreate(%tmp) ]; }

When I create a new ticket with the mail below, the status is set to
‘stalled’ (so it looks as if the mail is being parsed), the ‘X1’ line
above is logged, but there is no ‘X2’ line logged. It looks to me as
if $queue->TicketCustomFields is not returning the custom fields for
this queue.

I don’t know Perl very well so I’m not sure how to examine what
“custom_fields” is sent to - a simple output of that variable to the
log shows it is “RT::CustomFields=HASH(0x9bf5044)”

The mail used to test:

Status: stalled
CustomField.{Textline}: ABC

blah blah blah

RT version 3.4.5, CommandByMail version 0.5. What more information can I
give to help resolve this problem?

Thanks,
Keith

-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf
Of Keith Edmunds
Sent: Sunday, December 10, 2006 1:27 PM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] CommandByMail and Custom Fields

I’ve done a bit more research on this, and to keep it simple I created
an “Enter one value” custom field called ‘Textline’.

I added some debug lines to TakeAction.pm as follows (my lines marked
“>>>”):

    # Canonicalize custom fields
$RT::Logger->warning("X1");
    my $custom_fields = $queue->TicketCustomFields;
    while ( my $cf = $custom_fields->Next ) {
    $RT::Logger->warning("X2: cf=$cf");
        my %tmp = _ParseAdditiveCommand( \%cmds, 0, 

“CustomField{”.
$cf->Name .“}” ); next unless keys %tmp;
$create_args{ ‘CustomField-’ . $cf->id } =
[ _CompileAdditiveForCreate(%tmp) ]; }

When I create a new ticket with the mail below, the status is set to
‘stalled’ (so it looks as if the mail is being parsed), the ‘X1’ line
above is logged, but there is no ‘X2’ line logged. It looks to me as
if $queue->TicketCustomFields is not returning the custom fields for
this queue.

I don’t know Perl very well so I’m not sure how to examine what
“custom_fields” is sent to - a simple output of that variable to the
log shows it is “RT::CustomFields=HASH(0x9bf5044)”

Keith,

The value “RT::CustomFields=HASH(0x9bf5044)” just shows you that the
variable is an object of type RT::CustomFields. You can get more info about
the object by using the appropriate methods & attributes for that object.
These are in CustomFields_Overlay.pm, CustomFields.pm, RT::SearchBuilder,
and DBIx::SearchBuilder.

For example you can see how many custom fields are represented by this
object by logging $custom_fields->Count just before the loop.

The fact that the X2 line doesn’t get logged indicates that there are no CF
objects in $custom_fields. A couple of reasons why this might be true: the
queue has no ticket custom fields defined or it could be a permissions
issue.

Steve
Stephen Turner
Senior Programmer/Analyst - Client Support Services
MIT Information Services and Technology (IS&T)

The fact that the X2 line doesn’t get logged indicates that there are
no CF objects in $custom_fields. A couple of reasons why this might
be true: the queue has no ticket custom fields defined or it could be
a permissions issue.

Thank you, Steve - it was a permissions problem.

Rhetorical question: why doesn’t RT log anything when a CommandByEmail
command fails due to insufficient permissions?

Keith