Anyone ever done a where-clause on SessionAdmin.GetList?

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.

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?

Also, you don’t wrap a boolean value. I would only wrap string values…

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.

I tried this just now, but I still get trues:

Yours looks different than mine. Might just be the version.

@JasonMcD My apologies, after I checked several different combos’ I couldn’t get the whereClause to work at all.

No worries! I appreciate the sanity check.

1 Like

try just using

InUse=false

You should be sending this:

{"whereClause":"InUse=false",
"pageSize":0,
"absolutePage":0}

NVM not working for me either :confused:

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

OK. I was typing when you were.

Odd thing, it does not seem to respect anything in the whereClause at all.

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.

You need to go the other way.

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.

Show the input json from swagger (rest help), I can’t pull it up right now.

Bam:

image

Edit: Well, the zero would be a 2

Are you passing this to the BO or ? How are you trying to use this?

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.

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>

image

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?

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 :confused: