Killing User Sessions with a Function

I like kicking out all users every night. Technically “inactive” ones, but at 11PM, that’s basically all of them. It just feels right.

Anyway, I made an EFx to do this back in May (2024), and scheduled it with a Flow (Power Automate) to run at 10:58 PM each night.

Well, it always said it there were no sessions to kill, so I just assumed the data looked different at night, and never came back to it till today.

Looks like I blamed the wrong thing. I think the EFx was fine; it’s the Flow that fails.

I made a separate EFx just to show me active and inactive users. They are nonzero in Production as shown in Postman:

Now here is that same EFx in Power Automate (also Production) - all zeroes! And status is 200 OK.

image

So did I just mess up the Flow? Or is there something else going on here?

Anyway, I don’t know why I didn’t just schedule the deletion EFx in Epicor (instead of a Flow), but I did now and I’ll see what happens tonight.

For some fun background reading:

1 Like

Is the user the request being sent as also Security Manager in Power Automate?

2 Likes

Ah. No it is not.

Yes in Postman, No in PA.

I bet that’s it.

1 Like

You might need Global Security Manager - not sure

1 Like

That’s it!

image

I knew you were right as soon as you said it. Creating a new user also has the same restriction in REST. But since that’s the only time I’ve ever encountered the restriction, I just forgot all about that possibility.

3 Likes

Post script

Good news: Flow worked perfectly last night and deleted 88 inactive user sessions! Huzzah @mbayley !

Odd news: The scheduling of the Function (inside Kinetic) failed. I have not investigated; probably some obvious mistake I made. I just wanted to say that it’s ironic that the Flow worked better than native Epicor scheduling.

image

FYI, the scheduled EFx (not the Flow) was a fallback. Flow ran at 10:55; this ran at 10:58. Maybe it bombed because there were no sessions to delete. But it’s a moot point. I can fix the issue (or not) in time.

1 Like