[rt-users] Setting user CustomField through Perl Script
Jason Fenner
jfenner at vitamix.com
Thu Mar 30 11:01:44 EST 2006
I have tried your recommendation but I am getting this error message:
[Thu Mar 30 16:00:19 2006] [error]: Couldn't add CF value: Custom field
7 does not apply to this object (test2.pl:57)
I guess my question is regarding your example. Is $user supposed to by
a RT::Record object or a RT::User object?
The code I am trying is:
-------------------------------------------------------------------------------------------------------
my $CurrentUser = new RT::CurrentUser($RT::SystemUser);
# Try username first
# $CurrentUser->LoadByName($name) if $name;
#my $CustomFields = RT::CustomFields->new($CurrentUser);
my $record = new RT::Record($CurrentUser);
#my $user = new RT::User->Load("JDF");
my ($status, $msg) = $record->AddCustomFieldValue( Field =>'7', Value =>
'000 - Corporate');
$RT::Logger->error("Couldn't add CF value: $msg") unless $status;
print $CurrentUser->Id;
print $CurrentUser->Name;
---------------------------------------------------------------------------------------------------------------------
Ruslan Zakirov wrote:
>my ($status, $msg) = $user->AddCustomFieldValue( Field =>
>'Department', Value => 'XXX');
>$RT::Logger->error("Couldn't add CF value: $msg") unless $status;
>
>perldoc lib/RT/Record.pm
>perldoc lib/RT/User*.pm
>perldoc ...
>
>On 3/29/06, Jason Fenner <jfenner at vitamix.com> wrote:
>
>
>>Hi:
>>
>>I have a global CustomField called "Department" defined as type User in
>>my RT 3.4
>>
>>Through an external Perl script I query my Active Directory server for a
>>particular username and find a key called: Department. Once I find that
>>key, I want to set the above CustomField for that user in RT to that
>>same value.
>>
>>However, I am stumped as to what object method, etc you use with RT in
>>order to set a CustomField value for a user?
>>
>>Can anyone toss me any clues?
>>
>>Thanks in advance,
>>Jason Fenner
>>
>>_______________________________________________
>>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>>
>>Community help: http://wiki.bestpractical.com
>>Commercial support: sales at bestpractical.com
>>
>>
>>Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
>>Buy a copy at http://rtbook.bestpractical.com
>>
>>
>>We're hiring! Come hack Perl for Best Practical: http://bestpractical.com/about/jobs.html
>>
>>
>>
>
>
>--
>Best regards, Ruslan.
>
>
More information about the rt-users
mailing list