Problem handling user custom field in script

Hi,

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
http://lists.fsck.com/pipermail/rt-users/2006-October/042235.html).

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;
RT::LoadConfig();
RT::Init();

my $CurrentUser = new RT::CurrentUser();
$CurrentUser->LoadById(47);

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 );
$cf->Load(16);
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 :
IcalUrl
RT::User
0
16
And Can’t update it :
0 msg: Custom field 16 does not apply to this object

Someone to give me a piece of advice ?