Closed jsalatiel closed 3 years ago
The notequals does not work because it is apparently not supported by the status field (don't ask me why :wink:):
>>> glpi.list_search_options('Ticket')['12']
{'name': 'Status',
'table': 'glpi_tickets',
'field': 'status',
...
'available_searchtypes': ['equals']}
Your second try does not work because NOT is not a valid link
, from the search documentation:
link: (optional for 1st element) logical operator in [AND, OR, AND NOT, AND NOT].
Note there's a typo as they are two 'AND NOT' and no 'OR NOT'.
When the link
if not valid, it seems to fallback to an AND so you get the contrary of what you want. A quick test on my debug instance confirms it (I have 12 tickets but only one solved):
>>> len(glpi.search('Ticket', criteria=[{'link': 'NOT', 'field': 'status', 'searchtype': 'equals', 'value': '5'}]))
1
>>> len(glpi.search('Ticket', criteria=[{'link': 'AND NOT', 'field': 'status', 'searchtype': 'equals', 'value': '5'}]))
11
Thank you
Hi, I am having problems trying to make a search with multiple criterias. I have created a ticket using this api and if I do a simple search by name using the following criteria I can get the result as expected: criteria = [ {'field': 'name' , 'searchtype': 'contains', 'value': "^" + ticketName + "$" }
But I can not find a way to search for tickets with that name and status not '5' ( solved ). First I tried the following: criteria = [ {'field': 'name' , 'searchtype': 'contains', 'value': "^" + ticketName + "$" } ,{'field': 'status' , 'searchtype': 'notequals', 'value': "5" } ] but it returned empty.
Then I tried criteria = [ {'field': 'name' , 'searchtype': 'contains', 'value': "^" + subject + "$" } , { 'link': 'NOT', 'criteria': [ {'field': 'status' , 'searchtype': 'equals', 'value': "5" } ] } ] Also empty.
What am I doing wrong ?