Check if Custom Field is empty?

Hello,
I’m scripting a custom condition before a email will be sent.
I’ve tryed this: ($self->TicketObj->FirstCustomFieldValue(‘Solution’) =!
‘NULL’)

But it doesn’t work, could you help me please?

Thanks

View this message in context: http://requesttracker.8502.n7.nabble.com/Check-if-Custom-Field-is-empty-tp62360.html

Hello,On Wed, Aug 24, 2016 at 6:17 AM, PeterMairGO PeterMairGO@gmail.com wrote:

Hello,
I’m scripting a custom condition before a email will be sent.
I’ve tryed this: ($self->TicketObj->FirstCustomFieldValue(‘Solution’) =!
‘NULL’)

Unfortunately, at a minimum, your perl is wrong. You were looking for
‘!=’, not ‘=!’. However with strings you want ‘ne’ instead of ‘!=’.
The latter is for numeric comparisons.

my $a = ‘Hi’;

if ($a ne ‘Goodbye’) {
print “Good.\n”;
}

Some more things…

What version of RT are you running?

I would try a little script like this to test things out:

#!/usr/bin/perl

use strict;
use warnings;

use lib qw(
/opt/rt4/lib
/opt/rt4/local/lib
);

use RT -init;
my $t = RT::Ticket->new(RT->SystemUser);

$t->Load($ARGV[0]);

my $cf = $t->FirstCustomFieldValue(‘Solution’);

if (defined $cf) {
print “$cf\n”;
}
else {
print “NOT_DEFINED\n”;
}

-m