<< Back

The hidden ‘username variable’ available when running applications in Alteryx Server

Before I write this post, I must credit fellow Alteryx Ace Mark Barone, who provided a series of great responses in a post on the community which helped guide me on this subject area; also, Craig Bloodworth, my colleague and CTO of The Information Lab, who let me know this was actually possible!

Also, I say hidden, that’s not strictly true, it’s just not well known!

So what do I mean when I say ‘username variable’?

When a user runs an analytical app in Alteryx Server, you may want to use their information in order to manipulate how the application generates it’s output.

You could create a manual text box, where they enter there name, but of course, they may get their details incorrect, or they may just pretend they are someone else!

The ‘username variable’ allows this process to happen automatically, by grabbing the ID of the individual who is running the app.

So give me an example of how this could work in the real world…

Sure; let’s take the following usecase.

Please note the below is a fictional usecase

In our business we create and share applications with our different clients. In order create a secure barrier, we host our clients data in different databases; our server is also structured, so each client has access to their own Private Studio, ensuring any bespoke content is made available only to the correct client.

As part of our work, we ask our clients to submit their own information, which is then transferred into their respective database.

We were approached to convert this submission form into an Alteryx application.

We could approach this in two ways;

1. Create an analytic app for each client, with a output data tool in each app, pointing at the appropriate database

2. Use a single analytic app, where we capture the detail of the individual running the application and thus detour the data into the appropriate database

Of course, we are going to look at the second option, primarily because this would mean we can maintain our analytic app in a single location, which will reduce strain on our team.

So how can we do this?

Well, let’s start by building our app as if we would require our user to give their own details into the app, via a text box; in this simple example, I require my users to submit ratings for a given day, which I have set up using the ‘Date’ and ‘Numeric Up Down’ interface tools.

Given that I want to write the data into a database for the client (a company), rather than for the unique user, I will need to perform a lookup against a table with user names and their client name. To do this I will perform a lookup against the MongoDB which contains this information (each user is assigned to a private studio, which is the company name, which itself, is the suffix to the database with which they data needs to be entered into).

These streams can then be merged together and the client data written to the appropriate database.

Now, as I mentioned above, at present I have just created a ‘text box’ to allow our user to input their email address which can then be matched to the MongoDB data to get the appropriate private studio and client detail, lets now discuss how we can ‘hide’ this from our user, and their personal ID automatically be tracked by the application, to do this we need to complete the following steps…

1. On our text box input, remove the question name that we have given, so it’s blank, this can be done in the configuration pane

2. Also in the configuration pane, check the option ‘Hide control (for API development)’; this means the user won’t be shown this question

3. On the ‘annotations’ tab in the configuration window for the text box interface tool, change the ‘Name’ attribute to ‘__cloud:UserID’

This step truly is our ‘secret sauce’, it’s how this trick works.

This variable returns the unique identifier, which matches the, ID field given in the ‘users’ table in the MongoDB underneath our Alteryx Server.

We can then use this as our identifier to bring through the private studio detail through and write our data into the appropriate data.

So lets see this in action

The below video demonstrates the behaviour in a similar usecase to that highlighted above (form entry and result into specific table).

If you have any questions, make use of the Alteryx Community, and I’m sure there will be many of us to reach out and help!


Ben Moss

Leicester, UK

Leave a Reply

Your email address will not be published. Required fields are marked *