[resolved] Webservice SearchTicket with multiple States

Moderator: crythias

Post Reply
krasseoma
Znuny newbie
Posts: 7
Joined: 17 Feb 2021, 10:20
Znuny Version: 6.0.30
Real Name: S.

[resolved] Webservice SearchTicket with multiple States

Post by krasseoma »

I want to search all tickets with state "new" and "open". Anyhow I find no solution to combine both states in search.

What works (search for one state)

Code: Select all

$VAR1 = {
  'CustomerID' => '50320446',
  'OrderBy' => 'Up',
  'Password' => 'HIDDEN',
  'RequestMethod' => 'GET',
  'SortBy' => 'Created',
  'States' => 'new',
  'UserLogin' => 'webservice_user'
};
What is not working:

Code: Select all

Incoming data before (and after) mapping:
$VAR1 = {
  'CustomerID' => '50320446',
  'OrderBy' => 'Up',
  'Password' => 'HIDDEN',
  'RequestMethod' => 'GET',
  'SortBy' => 'Created',
  'States[0]' => 'open',
  'States[1]' => 'new',
  'UserLogin' => 'webservice_user'
};
Is there a way to search for State=new OR state=open?
Last edited by krasseoma on 02 Mar 2021, 15:01, edited 1 time in total.
root
Administrator
Posts: 3960
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Webservice SearchTicket with multiple States

Post by root »

Hi,

I guess it's the TicketSearch operation from the GenericInterface? Please show a little bit more details.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Webservice SearchTicket with multiple States

Post by crythias »

Try StateIDs
By default new is StateIDs=1 and open is StateIDs=4

This may potentially vary in your deployment. Go to Admin, State, and hover over the appropriate states, look at the Status bar of your browser for the State ID (Subaction=Change;ID=x)

A web search would look like:
Action=AgentTicketSearch;Subaction=Search;StateIDs=1;StateIDs=4

On the other hand:
https://stackoverflow.com/questions/306 ... uery-param
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
krasseoma
Znuny newbie
Posts: 7
Joined: 17 Feb 2021, 10:20
Znuny Version: 6.0.30
Real Name: S.

Re: Webservice SearchTicket with multiple States

Post by krasseoma »

Is there a way to use the names? Because we have a development and liveserver and I cannot guarantee that both systems have the same ids

@crythias: why do you use this subaction=change?

Is this necessary? I cannot find anything in this doc: https://doc.otrs.com/doc/manual/admin/6 ... 1.6.12.4.9
zzz
Znuny superhero
Posts: 889
Joined: 15 Dec 2016, 15:13
Znuny Version: All
Real Name: Emin
Company: Efflux GmbH
Contact:

Re: Webservice SearchTicket with multiple States

Post by zzz »

crythias is (also) talking about the web search (search subaction) but most attributes stay the same.
If you want to go by names, try States instead of StateIDs.

— Emin
Professional OTRS, Znuny & OTOBO services: efflux.de | efflux.de/en/

Free and premium add-ons: German | English
krasseoma
Znuny newbie
Posts: 7
Joined: 17 Feb 2021, 10:20
Znuny Version: 6.0.30
Real Name: S.

Re: Webservice SearchTicket with multiple States

Post by krasseoma »

In my second try I sent already "States"

Code: Select all

'States[0]' => 'open',
'States[1]' => 'new',
I copied it from webservice log. So this is how it is imported to otrs.

But why does it not work?
skullz
Znuny superhero
Posts: 621
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: Webservice SearchTicket with multiple States

Post by skullz »

Try

Code: Select all

States => ['open', 'closed'],  
krasseoma
Znuny newbie
Posts: 7
Joined: 17 Feb 2021, 10:20
Znuny Version: 6.0.30
Real Name: S.

Re: Webservice SearchTicket with multiple States

Post by krasseoma »

Now I tried following:

Code: Select all

$VAR1 = {
  'CustomerID' => 'HIDDEN',
  'OrderBy' => 'Up',
  'Password' => 'HIDDEN',
  'RequestMethod' => 'GET',
  'SortBy' => 'Created',
  'States[]' => [
    'new',
    'open',
    'closed successful',
    'closed unsuccessful'
  ],
  'UserLogin' => 'HIDDEN'
};
Still not working!
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Webservice SearchTicket with multiple States

Post by reneeb »

It should be without the "[]" after "States". How do you call the webservice? In the browser? With code (PHP, Perl, ...)? If the latter, please show some code.
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
krasseoma
Znuny newbie
Posts: 7
Joined: 17 Feb 2021, 10:20
Znuny Version: 6.0.30
Real Name: S.

Re: Webservice SearchTicket with multiple States

Post by krasseoma »

I use PHP for the webservice call.

Code: Select all

$requestParameter['States'] = ['new','open'];
it's done with curl_exec and for the query I use

Code: Select all

$query = http_build_query($parameters);
return preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $query);
here in preg_replace was my error!

correct replacement:

Code: Select all

return preg_replace('/%5B[0-9]+%5D/simU', '', $query);
Post Reply