ewsterrenburg / python-otrs

Pythonic interface to OTRS SOAP API
GNU General Public License v3.0
47 stars 27 forks source link

Search tickets between dates #37

Closed ytaogror closed 4 years ago

ytaogror commented 6 years ago

I'd like to find tickets between dates , when using only one DF is works ....

df1 = DynamicField(Name='ResolvedDate', Value='2018-08-01 00:00:00', Operator="GreaterThanEquals") df2 = DynamicField(Name='ResolvedDate', Value='2018-08-05 00:00:00', Operator="SmallerThan")

tickets = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df1]) -> works ok tickets = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df2]) -> works ok

... but when I combine two df's , it does not work at all.

tickets = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df1][df2]) -> ko

tickets = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df1] and [df2]) -> ko tickets = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df1] & [df2]) -> ko tickets = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df1 and df2]) -> ko tickets = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df1 & df2]) -> ko

please , could you help me ?

thank you in advance !

ewsterrenburg commented 4 years ago

@ytaogror

I honestly have no idea whether this is intended to be possible or not in the generic interface.

However, I can not make it work in anyway neither using python-otrs (where multiple dynamic fields should be a list), nor by directly calling the endpoint with a soap envelop. It seems that including the same dynamic field twice with different conditions has the result that the dynamic field part is being ignored altogether.

Best way to make this work seems to be ask for the tickets before and the tickets after, then take the intersection:

df1 = DynamicField(Name='ResolvedDate', Value='2018-08-01 00:00:00', Operator="GreaterThanEquals")
df2 = DynamicField(Name='ResolvedDate', Value='2018-08-05 00:00:00', Operator="SmallerThan")

tickets_after = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df1])
tickets_before = client.tc.TicketSearch(Queues='QUEUENAME',StateIDs=['2'],dynamic_fields=[df2])

tickets_between = list(set(tickets_after ) & set(tickets_before )))