Current user and department settings in rules and actions

How can I get the current user and current department and give it as a parameter for an action?
For example, if I wanted to create a Display popup action which shows me the current department (or current user), what would I have to put in the “Message” field of the Display popup action?

I tried many values, but none seem to work:
{DEPARTMENT}
(this was the closest, gave me “[UNDEFINED]”)
{:DEPARTMENT}
(empty)
{CURRENTUSER}
(shows “{CURRENTUSER}”)
{:CURRENTUSER}
(empty)
{USER NAME}
(doesn’t do anything, action doesn’t execute)
{:USER NAME}
(empty)
{SETTING:CURRENTUSER}
(empty)
{SETTING:USER NAME}
(empty)
{SETTING:DEPARTMENT}
(empty)

User: {USER NAME} Dept: {DEPARTMENT} are the correct Printer Tags

However, there is a slight quirk with this - there must be a Ticket created, otherwise you will get <blank> and [Undefined].

So there is no way to decide what the current department (or user) is outside of the ticket screen?

I would like to create a program setting with department and user values inside, so that I can call outside scripts for additional functions with these parameters. I would do that from a separate admin screen when there’s no ticket open.
I could set that program setting during ticket creation, but even then, it would be impossible to know if the user has changed the department (or logged on/off) since the setting was last updated.

Are these settings stored in the database somewhere that I can get it, or any other way to do it?

Nearly everything is stored in the DB, but due to the way elements are linked together, not all settings are available to all events.

For example, the event for User Login has access to [:Username] or {USER NAME} and [:RoleName], which is how I can set the Application Title:

But as you can see, the Department is not available until we create a Ticket, since the Department is linked to a Ticket Type. Even [:TicketTypeName] is not available on Login; it only becomes available after a Ticket is created (Order added).

@pipo, I just learned from @emre that these Program Settings are available to Automation Command:

for user: {:CURRENTUSER}, and for department: {:DEPARTMENT}

When you change the Rule and any Actions to use this, be sure to logout and login before testing…

That doesn’t work for me, I’m getting this result in the popup:

I’m using V3.0.35, maybe it only works in V4?

Yes V4 might work different here. I’ve also noticed rule executes before user department activates. I’ve fine tuned it too.

@pipo, according to your screenshot, you also missed the leading colon… the Setting is {:CURRENTUSER}, not {CURRENTUSER}.

You’re right. That was pretty dumb :smile:.

Anyway, when I type it right, it also doesn’t work:

So in V4, using this syntax, does it show the department and user even when there’s no ticket or is it just another way to write {USER NAME} and {DEPARTMENT}?

In v4, this works properly, even with no Ticket, but as I mentioned, after modifying Rule I had to logout and login for it to work.

These are not the same as the non-colon versions… they are tied to a Ticket.

Strange, when I tried {:DEPARTMENT} before, it didn’t work, and now suddenly it does.

For the username, I had to use @JohnS’s method of storing it at login time (Terminal Events).

So now it seems to be working most of the time (including when there’s no ticket):

It is not working all the time though. When you go to the management screen and back both values are gone, and I get this:

Does anybody have any idea why this is and possibly a solution?

That was why I’ve said V4 will work better because these values stores in cache and navigating to Manage screen clears cache. I’ve recently changed for V4 how it stores these values.

I see, that explains (and provides a partial solution).

I set the isLocal parameter of Update Program Setting to false so it stores it in the database instead of the cache, as you just explained in

and now the user name doesn’t disappear anymore after going to the Manage screen.

Now I just need to find a way to do the same for the department name.
Is there an event where I can catch when someone goes to the Manage screen, or an event where I can catch {:DEPARTMENT} before that?

Maybe the “Application Screen Changed” event? How does this event work? What are the possible values for CurrentScreen and PreviousScreen?
Does the flushing of cache happen before or after this event?

Ok, I worked out the “Application Screen Changed” event:

Possible values for CurrentScreen and PreviousScreen:

Nothing
LoginScreen
Navigation
WorkPeriods
EntityView
PaymentView
TicketView
TicketListView
AccountView
InventoryView
MarketView
ReportView
Management

So just set constraint CurrentScreen - equals - Management
for a rule to work when entering the Management screen
or
PreviousScreen - equals - Management
for a rule to work when leaving the Management screen

1 Like