Hi Experts,
I would like to extract name of the person who's running the workflow on Alteryx server for one my projects. For this I tried the function, GetEnvironmentVariable("USERNAME")
But this gave me just the remote desktop name while running from server and on local it gave me my name. So this didn't work for me.
Secondly I tried __cloud:UserId approach and it gave me so code which looked like a key. Is there any approach which could help me to extract the user name or email directly inside the workflow?
Solved! Go to Solution.
That __cloud:UserId is the GUID for the User in the MongoDB. Assuming you have default MongoDB under the hood on your server, you can use a MongoDB Input to pull the Users collection and match the ID to the user. When setting up the MongoDB for this, you will need the MongoDB admin password from the System Settings, otherwise you can ask IT to dump that collection to a DW table each week and hit it from there, but you then have your user table sitting somewhere else that needs to be protected.
The reason that the GetEnvironmentVariable did not work, is the user that it will be running under is a default one on the server unless you specifically have the workflow set up to run under user credentials (I don't recommend unless you need it, because it requires a lot more management). There is a difference between windows user and Alteryx user.
Thanks @KGT
If you have any sample workflow available, could you be able to share the same? Thanks in advance!
I do not and I don't currently have server so can't mock one up. The MongoDB tool may have been deprecated which would mean that the API is the best way to get the user details. Have a look at the following for that:
This post has a picture of the config on the tool:https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Get-username-Cloud-not-working... (4th post on the second page I think).
This post shows the API and getting it that way: https://community.alteryx.com/t5/Engine-Works/Introducing-the-Alteryx-Server-v3-API/ba-p/899228.
You can also check out these posts for possible options by @mbarone, however the Mongo Tool may have been deprecated.