[rt-users] problem handling user custom field in script

Nicolas nicolas at barna.be
Sun Apr 8 15:29:17 EDT 2007


I would like to change a use custom field by script and I can't find my way.

I've declared in the GUI (like said in

I can see it and change it in the modify /Admin/Users/Modify.html page

But by script no way. I can't see what I'm doing wrong :
% cat a.pl
#!/usr/bin/perl -w

use lib ("/opt/rt3/local/lib", "/opt/rt3/lib");

use RT;

my $CurrentUser = new RT::CurrentUser();

print "----- should see something and see nothing :\n";

my $CFs = RT::CustomFields->new($CurrentUser);
while (my $cf = $CFs->Next) {
   print $cf->Name;

print "-----\n";

print "----- Weird because I can find it :\n";

my $cf   = RT::CustomField->new( $CurrentUser );
use Data::Dumper;
print $cf->Name . "\n";
print $cf->LookupType . "\n";
print $cf->Disabled . "\n";
print $cf->Id . "\n";

print "And Can't update it :\n";
printf "%s msg: %s\n", $CurrentUser->AddCustomFieldValue(Field =>
$cf->Id, Value => "I want to update you");
% sudo perl a.pl
----- should see something and see nothing :
----- Weird because I can find it :
And Can't update it :
0 msg: Custom field 16 does not apply to this object

Someone to give me a piece of advice ?

More information about the rt-users mailing list