Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Validating User Selected Input File

carl_steinhilber
8 - Asteroid

I'm relatively new to Alteryx, but a seasoned programmer.

I'm trying to build an Analytics App that allows the user to browse for an input data file, but I would like to validate that file before processing to ensure it contains the required fields.

 

Something like:

IF input data does not contain fields [Name, Address, Date] THEN error message ELSE continue

I discovered the Field Info tool, but I'm confused how I can check the Field Input dataset for the existence of the proper fields and then return to the original Input Data dataset to continue processing. I searched pretty extensively, but the results I've found thusfar have just confused me more.  :-o

 

Thanks in advance,

-Carl

15 REPLIES 15
tcroberts
12 - Quasar

I think you are looking for the Test Tool. You can have the input data branch off, and perform the test. If it fails it will raise an error. Perhaps add a "Block Until Done" on the main branch, so that the main branch will only run if there is no Error in the Test Tool.

 

Let me know if you need help configuring this,

 

Cheers!

carl_steinhilber
8 - Asteroid

Thank you for responding, tcroberts

I'm unsure how I would use the Block Until Done to wait for the Test tool, since the recordset that the Test Tool is testing is actually the Field Info... it isn't technically processing all rows of the Input Data. I'd love to learn how, if you have some pointers.

 

Thanks again!

tcroberts
12 - Quasar

So I would pass the input dataset into the Block Until Done tool.; Then, the first anchor would perform your Field Info, followed by test, and your second anchor would go out to the rest of your workflow. This way, regardless of what it's actually processing, the whole dataset is getting sent down both paths (and then immediately reduced in the first path).

carl_steinhilber
8 - Asteroid

Of course!

Thank you, that should work!

tcroberts
12 - Quasar

One other thing is that you'll need to change your Workflow Properties so that the workflow will terminate if the Test Tool throws an error. You can see a post by @JordanB here that does this. In fact, doing it this way, I'm not certain you actually need the Block Until Done Tool. I just figured that it would ensure that the Test gets run before the rest of your workflow, so that time isn't wasted trying to process an invalid dataset.

 

Let me know if you have any trouble getting it to work,

 

Cheers!

carl_steinhilber
8 - Asteroid

Hmmm... delving into the Test tool, I'm not sure I can check for a specific field name in the "Name" column. It either tests all rows, or only the first row. So if I have a schema like

Field A | Field B | Field C | Field D

then the Field Info tool's resultset would be

 

Row |  Name        |  Type  |  ....
1   |  Field A     | etc
2   |  Field B     | etc
3   |  Field C     | etc
4   |  Field D     | etc

and if the Test tool checks for the expression [Name]='Field C', it's neither in all rows nor in the first row so the test would fail. 

Unless I'm missing something?

 

Thanks!

-Carl

tcroberts
12 - Quasar

What I did to get around this was add a Summarize Tool after the Field Info too and Concatenate the values of "Name" together.

 

Then, I wrote a expression like:

 

CONTAINS([Concat_Name], 'Field A') AND CONTAINS([Concat_Name], 'Field B') AND CONTAINS([Concat_Name], 'Field C')   ...

 

Hopefully this helps,

 

Cheers!

carl_steinhilber
8 - Asteroid

Wow, so many workarounds in a single solution. lol

Seems like it should be easier, but your recommendations work great. Thank you.

 

I wish there was a way to "design" the error message(s) to be prettier/more informative, but I'll take it.

 

Thanks again!

tcroberts
12 - Quasar

I agree, thats a great point and might make for a good Ideas submission. The way I usually do this is to make rather long Test names that describe what the issue is.

 

So in your case, it could be something like

 

"Invalid Columns: Requires 'Field 1', 'Field 2', 'Field 3'"

 

Then, if the test fails it would display:

 

'The test  "Invalid Columns: Requires 'Field 1', 'Field 2', 'Field 3'" failed on record #1'

 

Anyways, glad to hear I could help point you in the right direction,

 

Cheers!

 

Labels