Webservice SearchTicket with multiple States

Moderator: crythias

Post Reply
krasseoma
OTRS newbie
Posts: 5
Joined: 17 Feb 2021, 10:20
OTRS Version?: 6.0.30
Real Name: S.

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?

root
Administrator
Posts: 2563
Joined: 18 Dec 2007, 12:23
OTRS Version?: Znuny LTS and 4/5/6
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 LTS and ((OTRS) Community Edition CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

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

Do you want to contribute or want to know why ?

crythias
Moderator
Posts: 10147
Joined: 04 May 2010, 18:38
OTRS 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 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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
OTRS newbie
Posts: 5
Joined: 17 Feb 2021, 10:20
OTRS 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
OTRS superhero
Posts: 718
Joined: 15 Dec 2016, 15:13
OTRS Version?: 3.x–6.0.x
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 & ((OTRS)) Community Edition services: efflux.de | efflux.de/en/

Free and premium OTRS add-ons: German | English

krasseoma
OTRS newbie
Posts: 5
Joined: 17 Feb 2021, 10:20
OTRS 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
OTRS wizard
Posts: 382
Joined: 24 Feb 2012, 03:58
OTRS Version?: OTRS 6
Real Name: Skullz
Contact:

Re: Webservice SearchTicket with multiple States

Post by skullz »

Try

Code: Select all

States => ['open', 'closed'],  
My Github
OTRS Quick Links
If you are lucky, i write it for you 8)

Post Reply