JasonMcD
(Jason McDermott)
May 16, 2024, 1:16pm
1
If not, it’s fine. I’m just asking.
It looks like I can use GetFilteredSessionList
which is bizarre but what I need. (The filter of 2 = inactive users.)
But for the sake of argument, what is the syntax for the whereClause here?
I’m used to it being SQL syntax (wrapped in double quotes). So I expected to do
"InUse = 0"
But that did not work, nor anything else I tried. Nothing caused it to fail , but nothing filtered the results either.
Voice from the future
TL;DR 1: The where clause does not work ever . It’s not just me.
TL;DR 2: Instead use GetFilteredSessionList
, but the syntax for the widget is super weird .
aarong
(Aaron Gulley)
May 16, 2024, 1:42pm
2
Firstly, GetFilteredSessionList
is a POST
rather than GET
As for the GetList. You wanted to filter out InUse
I did it using
Are you getting any errors?
aarong
(Aaron Gulley)
May 16, 2024, 1:43pm
3
Also, you don’t wrap a boolean value. I would only wrap string values…
JasonMcD
(Jason McDermott)
May 16, 2024, 1:50pm
4
Right… is this a bad thing? It just requires a JSON input, being a POST. I think you are trying to tell me something, but I am missing it.
aarong:
I did it using
I tried this just now, but I still get trues:
Yours looks different than mine. Might just be the version.
aarong
(Aaron Gulley)
May 16, 2024, 2:14pm
5
@JasonMcD My apologies, after I checked several different combos’ I couldn’t get the whereClause to work at all.
JasonMcD
(Jason McDermott)
May 16, 2024, 2:18pm
6
No worries! I appreciate the sanity check.
1 Like
CSmith
(Clint Smith)
May 16, 2024, 2:25pm
7
try just using
InUse=false
You should be sending this:
{"whereClause":"InUse=false",
"pageSize":0,
"absolutePage":0}
CSmith
(Clint Smith)
May 16, 2024, 2:29pm
8
NVM not working for me either
JasonMcD
(Jason McDermott)
May 16, 2024, 2:30pm
9
Sorry still get the same. Are you getting only falses as intended?
I’m using the Swagger page. It says Request URL is this (I redacted sensitive parts):
https://SERVER/INSTANCE/api/v2/odata/COMPANY/Ice.BO.AdminSessionSvc/GetList?whereClause=InUse%3Dfalse&pageSize=0&absolutePage=0
JasonMcD
(Jason McDermott)
May 16, 2024, 2:31pm
10
OK. I was typing when you were.
CSmith
(Clint Smith)
May 16, 2024, 6:19pm
11
Odd thing, it does not seem to respect anything in the whereClause at all.
JasonMcD
(Jason McDermott)
May 16, 2024, 6:44pm
12
Exactly.
OK, new question.
I am switching to GetFilteredSessionList
and as was pointed out, it is a POST needing a JSON input.
So, that’s new territory for me.
I tried what I found on the Internet , which ended up as this:
JsonSerializer.Deserialize<ActiveSessionFilter>("{ \"filter\":2 }")
Checked Syntax and got the OK. Great!
Until I tried to save the EFx, and then I got this:
KillInactiveSessions.cs(81,21): warning CS0618: ‘JsonSerializer’ is obsolete: ‘Use the Newtonsoft serializer.’
KillInactiveSessions.cs(81,21): warning CS0618: ‘JsonSerializer.Deserialize(string)’ is obsolete: ‘Use the Newtonsoft serializer.’
OK… So I searched what others did here (@klincecum ) and saw that Epicor people use:
JsonConvert.DeserializeObject<ActiveSessionFilter>("{ \"filter\":2 }")
And that saves OK, but all I end up with in Postman is “Sorry! Something went wrong.”
I’ve never tried to deserialize to JSON before.
Life is hard.
klincecum
(Kevin Lincecum)
May 16, 2024, 6:47pm
13
You need to go the other way.
JasonMcD
(Jason McDermott)
May 16, 2024, 6:48pm
14
Also, I think I’ll just scrap the filtering idea altogether.
In the end, I think I need a for loop anyway, since the end objective of this endeavor is to delete inactive user session (at night). And the only delete I see is DeleteBy...ID
, so I can’t just slap a RowMod = D on all rows anyway.
This is wacky territory, as it’s not rooted in the database, as far as I can tell.
klincecum
(Kevin Lincecum)
May 16, 2024, 6:49pm
15
Show the input json from swagger (rest help), I can’t pull it up right now.
JasonMcD
(Jason McDermott)
May 16, 2024, 6:49pm
16
Bam:
Edit: Well, the zero would be a 2
CSmith
(Clint Smith)
May 16, 2024, 7:59pm
17
Are you passing this to the BO or ? How are you trying to use this?
CSmith
(Clint Smith)
May 16, 2024, 8:11pm
18
It works fine in swagger with { "filter" : 0 }
A POST is required for this method as well and the parameters:
{ "filter" : 1 }
{ "filter" : 2 }
Both work fine in swagger and postman.
JasonMcD
(Jason McDermott)
May 16, 2024, 8:23pm
19
I should have said that - sorry, I would be wondering also.
I’m using the Invoke BO Method widget and the input parameter is a variable (or expression, I suppose) of type <ActiveSessionFilter>
So, I am trying to turn
{ "filter" : 1 }
into the variable for filter
- but not that filter
; the filter
in my first pic of this reply.
Simple, right?
CSmith
(Clint Smith)
May 16, 2024, 8:53pm
20
Well, on my version 10.2.600.26 that is simply a string. My thought would be just set it to a “2” not sure what your ActiveSessionFilter type is but you will need that to properly setup the object to pass to the BO Method.
I asked it to create the variable and it created a simple string. So for yours I dunno, but I would try it as just 1
or 2
as the assignment for that. I would need to know the structure of that TYPE ActiveSessionFilter to point you further