Use APIs to Get User Information
As an application designer or story developer, you can use getUserInfo(), getTeamsInfo() and getRolesInfo() APIs, which return information about the current user in view time.
You can use getUserInfo() API to get information about the user currently using your analytic application or optimized story:
Sample Code
Application.getUserInfo()
It returns the following user information, for example:
Output Code
{ "id": "666666", "displayName": "John", }
In addition, you can use the following APIs respectively if you only want to get the team or role of the current user.
Sample Code
Application.getTeamsInfo()
The getTeamsInfo() API returns all the teams the current user belongs to, for example:
Output Code
[ { "name": "DataActionRole_Admin", "description": "" }, { "name": "127", "description": "127 Test" }, { "name": "MultiActionRole_Admin", "description": "" }, { "name": "Team_Supervisor", "description": "" } ]
Sample Code
Application.getRolesInfo()
The getRolesInfo() API returns all the roles of the current user, for example:
Output Code
[ "Admin", "BI Admin" ]
Note
To use getTeamsInfo() or getRolesInfo() API, viewers need to have the Read permission for the object type Team or Role.