Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By cosyxu
#824696
Hi Amo,

I'm currently using web-entry form function on PM Version 3.3.5, and I was wondering if there is any way that the dyanform can populate the current windows logged in username for browsers like (Chrome, Firefox), either setup in the javascript or a php trigger before the dynaform?

Thanks,
Yuan
User avatar
By amosbatto
#824704
If you are using the default web entry configuration, then there is no logged-in user in web entry form, because it uses the "guest" account. You can get info with the following JavaScript code, but it won't include the username:
PMDynaform.getProjectKeys()

If you marked the option "Authentication" > "Require User Login" in the Web Entry properties, then you can get the username of the logged-in user with this JavaScript in the Web Entry's Dynaform:
Code: Select all
var loggedUsername = $("#userInformation", top.document).text().match(/\((\w*)\)/)[1];
By cosyxu
#824713
amosbatto wrote: Mon Jun 03, 2019 10:44 pm Oh wait, are you talking about the user who logged into MS Windows? No, that is impossible, because that would be violation of web browser security.
Hi Amo,

Thanks for the reply.

I found some information from https://stackoverflow.com/questions/117 ... t-username, but it works only for IE broswer, so I thought maybe there are some other ways to do it.
Code: Select all
function username()
          {   
            var wshshell=new ActiveXObject("wscript.shell");
            var username=wshshell.ExpandEnvironmentStrings("%username%");
            return username;
          }

Thanks,
Yuan
User avatar
By amosbatto
#824716
You could create a program that is installed on all the Windows machines used by your users, which is a REST server that could be called with JavaScript inside your Dynaform.

The program would get the Windows' logged-in user like this:
https://stackoverflow.com/questions/330 ... out-domain

The address for the REST endpoint would be "localhost" and you can use the $.ajax() function in JavaScript to call it. Here is an example of using $.ajax():
https://wiki.processmaker.com/3.2/JavaS ... ing_jQuery

Of course this solution would be an insane amount of work on your part to implement, but it is probably what you have to do. It is far easier to make your users login to ProcessMaker.
By cosyxu
#824746
amosbatto wrote: Tue Jun 04, 2019 12:19 am You could create a program that is installed on all the Windows machines used by your users, which is a REST server that could be called with JavaScript inside your Dynaform.

The program would get the Windows' logged-in user like this:
https://stackoverflow.com/questions/330 ... out-domain

The address for the REST endpoint would be "localhost" and you can use the $.ajax() function in JavaScript to call it. Here is an example of using $.ajax():
https://wiki.processmaker.com/3.2/JavaS ... ing_jQuery

Of course this solution would be an insane amount of work on your part to implement, but it is probably what you have to do. It is far easier to make your users login to ProcessMaker.
Hi Amo,

Thanks for the solution you provided.

Just to confirm what I understand, does it mean that I need to: :idea:

1. Build a REST service on a new server to get windows logged-in username. (C#/ASP.net).
2. Then in the Dyanform of ProcessMaker, it uses ajax to call this REST service(GET) and then return the username.
3. Once I get the username, I can populate it on the Dynaform, :!: BUT, because this is a web-entry form, so it still use 'Guest' user to create the new case, since I only capture the windows users(those users are not ProcessMaker Users).

This is what you suggested? :?:

Thanks,
Yuan
User avatar
By amosbatto
#824767
Yes, that is what I'm suggesting. If your first task in the process uses Value Based Assignment, then you can use JavaScript in the Web Entry form to get the Windows username and then use that information to set a hidden field in the Dynaform which is associated with the the variable used by Value Based Assignment in the first task of the process. For example, if the windows user is "bob", then set the hidden field to 1234567890abacdef1234567abacde (the ID for user Alice) so Alice will be assigned to the first task in the process.

By the way, Web Entry has an option in 3.2.2 and later to allow the user to login when filling out the web entry form.
By cosyxu
#824840
amosbatto wrote: Fri Jun 07, 2019 1:30 am Yes, that is what I'm suggesting. If your first task in the process uses Value Based Assignment, then you can use JavaScript in the Web Entry form to get the Windows username and then use that information to set a hidden field in the Dynaform which is associated with the the variable used by Value Based Assignment in the first task of the process. For example, if the windows user is "bob", then set the hidden field to 1234567890abacdef1234567abacde (the ID for user Alice) so Alice will be assigned to the first task in the process.

By the way, Web Entry has an option in 3.2.2 and later to allow the user to login when filling out the web entry form.
Hi Amo,

Thanks for your reply.

Yes, since processmaker 3.2.2, web entry has an option to allow the user to login, however what I want to achieve here is single-sign-on where the user won't need to enter their username and password. And when the windows users completed the form, in the workflow it will assign to an admin user for review.

Again, like you suggest, it requires a Restful service to get windows logged-in username when an user open a web-entry form.

PS: ProcessMaker has the SSO function but that is allow the use to login processmaker application not the web-entry form.

Thanks
Yuan

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]

Betvisa clone scripts are pre-built software solut[…]

A Bet365 Clone Script is essentially a ready-made […]