List users beloning to CustomerID using SOAP

Moderator: crythias

Locked
Nicsoft
Znuny newbie
Posts: 53
Joined: 12 Aug 2010, 14:58
Znuny Version: 2.4
Location: Stockholm
Contact:

List users beloning to CustomerID using SOAP

Post by Nicsoft »

Hello,

I wonder if there is any efficient way to get a list of all customer users beloning to one customer company using the SOAP interface?

The only way I can find is

1. Get a list of all customer users
2. Get a list of all companies
3. Iterate through all customer users. For each iteration, get all data for that user.
4. Extract the CustomerID form the user data.
5. Get the company name from the company list using the CustomerID as key.

This is way to much overhead. I do this with only two users and I have registera about 20 companies. It's a poor machine but I think 1-2 s for two users is still a lot. What happens when I have 30 customer users, or 1000...? Unfortunately, nothing related to the customer users' companies is present in preferences (and I guess it's not the point).

Another way to do, which I haven't tried, is to chose which company you want to get the customer users for. But this is not better, you still need to iterate through all customer users data in order to get the customerID.

Is there a way to do this wih a lot less overhead?
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: List users beloning to CustomerID using SOAP

Post by crythias »

select * from users where CustomerID=xxx

ok. via soap..
well
Kernel/System/User.pm
only uses these fields to search:

Code: Select all

548	    my @Fields = qw(login first_name last_name);
549	    if (@Fields) {
550	        for my $Entry (@Fields) {
551	            $SQL .= ", $Entry";
552	        }
553	    }
Line 548 corresponds to the third entries in the User Map of Config.pm/defaults.pm
So, it seems to me that you could add customer_id in line 548 and then use the UserSearch API

Code: Select all

510	    my %List = $UserObject->UserSearch(
511	        Search => '*some*', # also 'hans+huber' possible
512	        Valid  => 1, # not required
513	    );
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Nicsoft
Znuny newbie
Posts: 53
Joined: 12 Aug 2010, 14:58
Znuny Version: 2.4
Location: Stockholm
Contact:

Re: List users beloning to CustomerID using SOAP

Post by Nicsoft »

Thanks!

You are refering to the UserObject. That is for agents, isn't it? CustomerUserObject is for customer user I guess, am I rigth? Anyhow, it didn't work using UserObject->UserSearch. CustomerUserObject has got CustomerSearch. Tried it and it works, extremly slow as well.

I found another way of doing it using CustomerUserObject->CustomerIDs. Even this is slow but I think it is faster at least, didn't do any real benchmarking. I'll stick with this one if I don't get better suggestions.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: List users beloning to CustomerID using SOAP

Post by crythias »

You're right. CustomerUser. Concepts should have similarly applied.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Locked