We're excited to announce that we'll be partnering with Credly starting October 19th - see what this means and read the announcement blog here!

Engine Works

Under the hood of Alteryx: tips, tricks and how-tos.
mceleavey
16 - Nebula

I thought I would open this blog by pointing out that this was all my work, and wasn’t at all massively influenced by @TheOC, however, even if it were all his idea, I hired him and therefore I’m a genius by proxy.

 

Them’s the rules.

CristonS_0-1621979323508.png

 

I was working with a client who I’m going to call Jeff. I will be producing a full use case on this at a later date, so I won’t be going into the details of that here.

 

A situation arose where the chained app functionality only got us so far and we needed the ability to individually tailor the second chained app according to the parameters of the first.

 

“McEleavey, you Brobdingnagian cognoscente,” spoke Jeff, “how on Earth do we pass through Value X and have this influence the wording in the Interface Designer in the second app?”

 

This was a confusing one. I’ll expand on the required sorcery.

 

The Challenge

Let’s say you have the following data set:

 

CristonS_1-1621979466093.png

 

This is a representative sample of 28,000 employees, who collectively report to around 2,000 managers. These managers need access to manually over-write the Monthly Figure on an ad-hoc basis.

 

I needed to write an application to be deployed via the Gallery, that allows the manager to select an employee, among other things, and then have the information returned, so it will show the employee, their monthly figure etc.

 

Then, the manager will be able to input a new figure, but the default value in the entry box needs to be the current monthly figure. So, this needs to be dynamic according to the employee that has been discussed.

 

This would mean the manager would then be presented with the following:

 

CristonS_2-1621979537855.png

 

CristonS_3-1621979561160.png

 

 

The tailoring of the wording in the second app to show the name and monthly figure of the selected employee is not possible, right?

 

Jeff thought he’d stumped me.

 

CristonS_4-1621979615200.png

 

It was Friday and my brain was basically doing the Badgers song, so I decided to go and have a little drink.

 

Passing through parameters for interface tools is simply achieved by outputting the appropriate file from the parent application to be consumed by each tool, for example drop-down lists. However, the wording for each one and the default values in each box need to be dynamic.

 

How would I do such a thing?

 

The answer was relatively simple and required only that I hire someone smarter than myself.

 

I had built the apps and had them all chained together, the parameter files were all outputting and being loaded in as expected and almost all was good with the world aside from the pesky bits I couldn’t make dynamic.

 

Then, I had an idea. I had messed around with the XML in the workflow files before, so I thought, what if I load in the XML from the app to which I’m chaining, amend it in a macro and drop out the file. Unfortunately, I was never able to get the file to save without corrupting and so the idea was dropped.

TheOCTheOC

 

However, at this point I thought I would bring in another brain and given the time of day and nerdiness of the challenge I was reduced to bringing in @TheOC, who I found sniffing around the bins.

 

I told him to put down his vase of Lambrusco and explained the problem. Against all odds he arrived at an incredibly simple yet stunningly effective solution.

 

We were going to dynamically hard code the chained app.

 

Yes, that’s right. Dynamic Hard Coding.

 

The Sorcery

We had our first app which simply asked the user to input the Employee ID they wished to amend, and that would then trigger a chained app.

 

So, we started with this:

 

CristonS_6-1621979788060.png

We then built the chaining into the Interface Designer as follows:

 

CristonS_7-1621979819153.png

 

Ok, so far, it’s just the standard app chaining you’ve come to know and love, but there’s more.

 

I needed to dynamically determine what Dynamic Hard Coding Part 2.yxwz actually looked like, and I needed to make sure every user got their own version every time.

 

This meant building a version of Part 2 as a template, which we would load, amend, and save as Part 2, to which we would then chain. Are you still following?

 

CristonS_8-1621979865370.png

 

To do this, we would open the Part 2 Template file, which looks like this:

 

CristonS_9-1621979909490.png

 

As you can see, the text for the Numeric Up Down tool contains hard-coded values, with parts of the text changed to represent what will be over-written.

 

First, we used an Input tool to load in the Part 2 Template, using a Flat ASCII file type:

 

CristonS_10-1621979958681.png

 

Ensure you check “Allow long lines” and increase the record length to 6500 (the maximum allowed) to be sure all characters are included:

 

CristonS_11-1621979978943.png

 

We were now presented with all characters in the XML of the entire workflow.

 

Secondly, we apply the amendments to the parts of the text to be dynamically overwritten, and then we save out the template as the Part 2 file to which we will chain.

 

Following this revelation which @TheOC came up with during the early hours of Saturday morning while I was out partying and kissing girls on the mouth, everything became incredibly easy and we both suddenly realised what we had discovered. We can literally change anything in the second app according to logic determined in the first.

 

We can change detours, switch containers on and off, change wording dynamically, change all, logic…

 

The basic flow is as follows:

 

Application 1 runs as a normal app, but also loads in Application 2 Template as a Flat ASCII file. The required changes are made to this file and it is then saved as Application 2 (therefore always retaining the template version).

 

CristonS_12-1621980199361.png

 

Here you can see the changes are being applied to the “Dynamic Hard-coding Part 2 Template” app. These changes are then being saved out to “Dynamic Hard Coding Part 2.”

 

Application 1 completes and chains to Application 2.

 

The flow looks like this:

 

CristonS_13-1621980333356.png

 

CristonS_14-1621980359049.png

 

Importantly, when chaining, either use the %Engine.TempFilePath% as the folder location for the template and the output, or simply leave this blank and only use the file name. This will allow the user temp folder to be used, and therefore if you have many users hitting the files simultaneously, they will always be operating their own version.

 

And there you have it. Jeff had not stumped me. Keep trying, Jeff.

 

Dynamic Hard Coding.

 

Magic.

 

Image credit to Jarkko Mänty

 

Comments
mceleavey
16 - Nebula

Some very minor, almost insignificant thanks go to @TheOC for this.

Hardly worth mentioning, really.

 

Also, the enigmatic Jeff.

 

Also also, @danilang for pointing out this was very cool and wondered why I only got one like for the idea in a solution.

Dan, it's not a popularity contest. I didn't cry myself to sleep that night, hardly at all.

 

M.

TheOC
12 - Quasar

oh that 'TheOC' sounds like a massive loser...

Really cool post Chris! Big fan of the term 'Dynamic hard coding' 😁. Hopefully this will help some server users unlock some potential of analytic apps!

Jeff_Neklason
6 - Meteoroid

To the contrary @TheOC, you sound like the brilliant and eccentric one... and that Jeff guy sounds amazing with his clever questions.

 

Really great work on this Chris! 

Emil_Kos
16 - Nebula

Hi @mceleavey,

 

Great article. It was super fun to read it.

 

Hi @TheOC,

 

Well done 🙂 

mceleavey
16 - Nebula

Thanks Emil, and "Jeff" 😉

 

 

DanHare
10 - Fireball

Holy Moly, that's some 4GL stuff there !

mceleavey
16 - Nebula

And it wall all me, @DanHare.

Me, and nobody else.

TheOC
12 - Quasar

@mceleavey stop flirting with me

camerondsteele
5 - Atom

Did this work on the gallery? Last time I tried this (admittadly several years ago), it didn't work on the gallery.

DavidP
16 - Nebula
16 - Nebula

@mceleavey@TheOC  this is awesome!

 

I'm definitely going to play around with this!

mceleavey
16 - Nebula

@camerondsteele , yes we're running this as a multi-chained app through the gallery. The full use-case is more complex, but the bit we found was tripping us up initially was file-pathing.

I think we'll do a video of the use case in future going through the full details, but yes, we have multiples of these working through a gallery servicing 28,000 people.

 

M.

mceleavey
16 - Nebula

Thanks @DavidP !

mceleavey
16 - Nebula

@atcodedog05  and @Qiu , I thought this would interest you.

 

M.

danilang
18 - Pollux
18 - Pollux

So, who is more the genius?  The Genius or the one who recognized the genius of the Genius's idea?

 

Good job here!

 

Dan 

Qiu
17 - Castor

@mceleavey 
This looks awesome and already in my bookmark.

Thank you much and can always learn so much from you.

btw, begin to doubt about the relation between you and @TheOC 😁

mceleavey
16 - Nebula

@danilang ,

 

I'm a genius by proxy.

 

My question to @TheOC is...

 

 

the who follows him.gif

atcodedog05
20 - Arcturus

Hi @mceleavey 

 

Yes, thats right if we cant make it happen through workflow or files let break into the XML and get hard core 😎

 

This is one of the lesson which i have been constantly seeing/learning especially from @danilang techniques, lot other posts and people.

I was discussing on a post with @TheOC i guess. That Is everything really XML ? and can anything really be edited through XML ? 😅

 

Overall great story and a great usecase 🙂. A new direction to think in, to dynamically customize the app. This is just the beginning with this we can totally change the apps interface questions by writing them from a choices of XML code to the app template.

 

This was a great treat. Thank you @mceleavey & @TheOC 🙂

mceleavey
16 - Nebula

Thanks @atcodedog05 ,

 

Yeah, it opens up an array of possibilities. Perhaps even an XML building wizard that allows for dynamic app creation etc.

 

I'll leave that to the smarter people.

 

M.

atcodedog05
20 - Arcturus

Hi @mceleavey 

 

I thought you were genius by proxy 😏

 

Anyways looking forward to much more possibilities from this concept. I am sure you will be coming up with much more usecases too  🙂

mceleavey
16 - Nebula

Yeah, @atcodedog05 .

We've actually built a few of these which I'll be writing up as full use cases in the future along with @Jeff_Neklason  .

atcodedog05
20 - Arcturus

@mceleavey  Cool!! looking forward to it 🙂

Thableaus
17 - Castor
17 - Castor

What a nice hack @mceleavey 

 

This post is super helpful. That's why I think nothing is impossible with Alteryx, you just gotta think harder to be able to make it.

suby
9 - Comet

 @mceleavey Its way too an advance topic for me but will get there you add a great value to the Alteryx Community.

 

Thanks.

mceleavey
16 - Nebula

Thanks @suby, you're right, you'll get there!

 

Thanks @Thableaus. I agree, if I can't do it in Alteryx I assume that's my lack of ability, not the platform.

 

Thanks @atcodedog05

apathetichell
16 - Nebula

Everyone has glanced over the best part of this post - the description of Durham night life. Who knew! Sounds much livelier than Gateshead.

Jeff_Neklason
6 - Meteoroid

@apathetichell You are assuming that @mceleavey ever leaves his house... I believe that part was just a dream