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
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@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
The rt-users Archives
Community help: http://wiki.bestpractical.com
Commercial support: sales@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: Careers — Best Practical Solutions
Best regards, Ruslan.
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:
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)
look into Configuration->Custom FIelds->CF XXX->Applies to.
I guess my question is regarding your example. Is $user supposed to by
a RT::Record object or a RT::User object?
RT::User is a RT::Record, it’s subclass of the RT::Record class.
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;
your code is wrong, Load doesn’t return object, but changes state of
the object. Code should be:
my $user = RT::User->new( $RT::SystemUser );
$user->Load(“JDF”);
die “Couldn’t load user” unless $user->id;
my ($status, $msg) = $user->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 …
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
The rt-users Archives
Community help: http://wiki.bestpractical.com
Commercial support: sales@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: Careers — Best Practical Solutions
–
Best regards, Ruslan.
Best regards, Ruslan.
Ok, that makes sense. I tried it now and it works good. Two other
things though…
- How would you work in the reverse, meaning, how would you print what
value(s) a certain CF has set?
- Where is the structure of the RT clases documented? How does one
find what class is related to which one?
Ruslan Zakirov wrote:>On 3/30/06, Jason Fenner jfenner@vitamix.com wrote:
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)
look into Configuration->Custom FIelds->CF XXX->Applies to.
I guess my question is regarding your example. Is $user supposed to by
a RT::Record object or a RT::User object?
RT::User is a RT::Record, it’s subclass of the RT::Record class.
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;
your code is wrong, Load doesn’t return object, but changes state of
the object. Code should be:
my $user = RT::User->new( $RT::SystemUser );
$user->Load(“JDF”);
die “Couldn’t load user” unless $user->id;
my ($status, $msg) = $user->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@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
The rt-users Archives
Community help: http://wiki.bestpractical.com
Commercial support: sales@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: Careers — Best Practical Solutions
–
Best regards, Ruslan.
–
Best regards, Ruslan.
Does anyone know what method to use in a perl script in order to print
out Values are set for a certain customfield of a certain user?
Thank You in advance,
Jason Fenner
Jason Fenner wrote:
perldoc lib/RT/Record.pmOn 3/30/06, Jason Fenner jfenner@vitamix.com wrote:
Does anyone know what method to use in a perl script in order to print
out Values are set for a certain customfield of a certain user?
Thank You in advance,
Jason Fenner
Jason Fenner 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
The rt-users Archives
Community help: http://wiki.bestpractical.com
Commercial support: sales@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:
Careers — Best Practical Solutions
The rt-users Archives
Community help: http://wiki.bestpractical.com
Commercial support: sales@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: Careers — Best Practical Solutions
Best regards, Ruslan.