show screen to certain group only


In service, we have two different usergroups who needs different kind of information from service module. I have created a screen for both of them, but i do not know, how to present one screen to one group and the other to second group. I know how to show screen to one person only (for testing purposes). Tried to change user -> group, but did not seemd to work.

if (getVariable("activeUser") == "222")
setVariable("url", getProgramTicket() + "&action=doScreenDefinition&idString=ej_viewTicket_80_aspa&entryId=" + getVariable("id"));

I appreciate, if somebody can help me with this, please.



RE: show screen to certain group only

Hi Ingar!

To get a list of the variables available through getVariable() you could do something like:

Map m = getVariables();
  print(m.getKey() + "|" + m.getVal() +"\n");;

Which gives you (as an example):


As you can see, usergroup is not one of them.


What you can do is to use getVariable("activeUser") to find the usergroup:

User u;

So, just do a check on u.getValue("group").

Av: Hans Wilhelmsen 30. maj 2018

RE: show screen to certain group only

Thanks Hans

Works like a charm.

Av: Ingar Mölder 30. maj 2018

RE: show screen to certain group only

Hans' code is correct, but I would advice to use User u = getActiveUser(); instead as it uses the cached version of the User instead of loading the object all over.

You can do it like this:

// Loads the user and fetches the group
User u = getActiveUser();
String group = u.getValue("group");

// If group is the only thing you need, do this:
String group = getActiveUser().getValue("group");

You won't notice the difference with only one change like this, but I always try to optimalize the code for better load time.

Av: Simen Mostuen Iversen 30. maj 2018