[rt-users] "No object mapping for field" when referencing the UserObject of a MembersObject...
Ruslan Zakirov
ruslan.zakirov at gmail.com
Thu May 21 14:12:41 EDT 2009
There is example in:
http://wiki.bestpractical.com/view/CodeSnippets
On Thu, May 21, 2009 at 10:11 PM, Ruslan Zakirov
<ruslan.zakirov at gmail.com> wrote:
> As group may have another group as meber as well as user, so records
> in GroupMembers and CachedGroupMembers objects reference Principals.
>
> If you are looking for users only that are members of a group then
> it's easier to do the following:
>
> my $group = ...
> $group->Load...
>
> my $users = $group->UserMembersObj;
> while ( my $user = $users->Next ) {
> ...
> }
>
> On Thu, May 21, 2009 at 9:46 PM, Johnathan Bell
> <johnathan.bell at baker.edu> wrote:
>> Please let me know if this is supposed to go to RT-Users or RT-Devel.
>>
>> I'm trying to write a utility to interface with Request Tracker, and
>> part of what that utility has to do is get the members of some user
>> created groups. Just sub in actual groups for what you want in there,
>> CurrentUser works and is already initialized by the time my program gets
>> here. Mostly borrowing this code from the old rtimportldap script, I
>> came up with this:
>>
>> --code--
>> # RT Group
>> $groupObj = new RT::Group($CurrentUser);
>> $groupObj->LoadUserDefinedGroup($groupName);
>> $groupObj->Id() || die "Group ".$groupName." not found in
>> RequestTracker";
>>
>> $groupMembersObj = $groupObj->MembersObj();
>> print $groupObj->Id().":".$groupObj.":".$groupMembersObj.":"
>> .$groupMembersObj->Next()->UserObj()."\n"; ## This creates an error
>> while ( $groupMember = $groupMembersObj->Next() )
>> {
>> $groupMemberUser = $groupMember->UserObj();
>> print $groupMemberUser->Name()."\n"; ## This does too
>> #$memberName = $groupMemberUser->Name();
>> #push(@rtMembers, $memberName);
>> }
>> --/code--
>>
>> What it seems is that GroupObj->MembersObj()->Next()->UserObj() causes
>> the problem, as UserObj() returns, not a UserObject, but a string
>> stating "No object mapping for field" Attempting to use the Name()
>> function of course doesn't work because "No object..."->Name() doesn't
>> make sense... What's going on?
>>
>> Thanks,
>> Johnathan
>>
>> --
>> Johnathan Bell
>> Internet System Administrator, Baker College
>>
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Best regards, Ruslan.
>
--
Best regards, Ruslan.
More information about the rt-users
mailing list