I want my interface to show the currently logged in users for application in the text field. Can someone please help in getting the solution for this ?
Discussion posts and replies are publicly visible
There is a function for this
docs.appian.com/.../fnc_people_loggedinuser.html
HI Stefan,
The function only provide the current logged in user but not the list of all users who have logged into the application. I need to display the count and name of all users who use particular application
This information is not directly available. The log file login-audit.csv is as close as you can get to information about logins. The plugin
https://community.appian.com/b/appmarket/posts/user-login-details
seems to not work anymore.
are there not any other alternatives to find out all the logged in users in appian ?
Not OOTB. Maybe there is a Java API available.
Why do you need this?
I need to display the count of logged in users of different groups in a tabular format in my interface. Its a part of customer requirement. They need to know how many users are currently logged in to the application using interface.
Do you know what they do with this information?
Number of group members is not good enough?
no idea on what they are going to do with this info..... for now how can I retrieve the count is the main problem....any possible means of doing it ?
AFAIK not OOTB. Would need some digging into Appian Java API and if there is something available (see deprecated plugin above) a custom plugin.
Agree with Stefan there isn't really anything OOTB to satisfy your requirement here. However you may be able to utilize the Execute Stored Procedure plugin to record users interacting with the form, then display the stored data within the form itself, to show which users are logged in.
Note, the plugin's function fn!executestoredprocedure() is not designed to modify data, which is noted on the App Market page. However, I have used it to successfully to record auditing/logging type data in similar situations. I cannot speak to if the function will be modified in the future to physically prevent this. But, this example will update a login data set each time the a!textField() is interacted with. In a short time playing with it today, I was not able to get the auto-refresh to work (intended to have it update every 30 seconds, automatically), but it is refreshing correctly based on refreshOnVarChange, in which you can set any variables that users interact with.
Created on Appian 20.3, MSSQL database.
Table:
CREATE TABLE [dbo].[test_login_audit]( [id] [int] IDENTITY(1,1) NOT NULL, [user] [varchar](100) NULL, [loginTime] dateTime NULL ) ON [PRIMARY] GO
Stored Procedure, results in one row per user with the latest form interaction time:
CREATE PROCEDURE [dbo].[test_usp_login_audit] @user varchar(100), @loginTime dateTime AS BEGIN DECLARE @count int = (SELECT COUNT(*) FROM dbo.test_login_audit WHERE [user]=@user) IF @count = 0 BEGIN INSERT INTO dbo.test_login_audit ([user],loginTime) VALUES (@user,@loginTime) END ELSE BEGIN UPDATE dbo.test_login_audit set loginTime = @loginTime WHERE [user]=@user END SELECT loginTime from dbo.test_login_audit WHERE [user]=@user END GO
Interface, this will log an interaction on load and any time the Test Field is modified:
a!localVariables( local!testField, local!audit: a!refreshVariable( value: fn!executestoredprocedure( dataSourceName: "java:comp/env/jdbc/YOUR_DB_CONNECTION", procedureName: "dbo.test_usp_login_audit", inputs: { {name: "user", value: tostring(fn!loggedInUser())}, {name: "loginTime", value: now()} } ), /*refreshInterval: 0.5,*/ /*refreshAlways: true,*/ refreshOnVarChange: local!testField ), { a!textField( label: "Audit Result", value: local!audit, readOnly: true ), a!textField( label: "Test Field", value: local!testField, saveInto: local!testField ) } )