[rt-users] update user custom field value via script

Patterson, Craig crpatter at ci.grand-rapids.mi.us
Thu Oct 4 10:02:52 EDT 2007


My version is 3.6.4

I'm working on a script to update users' data from LDAP.  Everything is
working fine for the most part, but updating a custom field.

If I use code like this, the value is "updated"...

my $CFObj = new RT::CustomField($RT::SystemUser);
$CFObj->Load('Department');

$UserObj->AddCustomFieldValue (
	Field => $CFObj->id,
	Value => $department,
	RecordTransaction => 1
);

The problem with this approach is that it doesn't update the record, it
creates new record and disables the old value.

So, I'm attempting the update the record like this...

my $CFs = $UserObj->CustomFields;
while (my $CF = $CFs->Next){
	if ($CF->Name eq 'Department'){
		my @cfAttribs = ('CONTENT');
		my %cfArgs = {
			CONTENT => $ARGS{'Department'}
		};
		
		my @results = $CF->Update(
			Attributes => \@cfAttribs,
			ARGSRef => \%cfArgs
		);
		last;
	}
}

... which is not updating the record.

I've dug through the wiki and through the mailing list, but all examples
I've found use the AddCustomFieldValue method.

Any Suggestsion

Craig Patterson
Application Developer
Northrop Grumman IT/City of Grand Rapids
crpatter at grcity.us



More information about the rt-users mailing list