[rt-users] Look up User by Attribute in Scrip

Ram ram0502 at gmail.com
Sat Oct 27 12:59:39 EDT 2012


> On 10/26/2012 04:52 PM, Ram wrote:
>> Hey folks,
>> I'm writing a scrip to help us manage our voicemails in RT. The
>> voicemails arrive via email as attachments and the extension of the
>> recipient is the only distinguishing characteristic in the email. How
>> can I load an RT user in a script given only their work telephone?
>
> You want the LoadByCols method provided by DBIx::SearchBuilder::Record.
>
> my $user = RT::User->new( RT->SystemUser );
> $user->LoadByCols( WorkPhone => "1234" );
>
> if ($user->id) {
>      # loaded!
> } else {
>      # couldn't find that user...
> }
>
> Note that WorkPhone isn't forced to be unique, so you should make sure
> that you keep it unique if you're going to load by it.

Awesome, thanks!! Yep our phone extensions are unique so it'll be fine.
ram



More information about the rt-users mailing list