Alteryx Designer Desktop Discussions

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

Formula on Action tool - Parse Error

JArtNaranjo
7 - Meteor

I looked the forums for this issue and couldn't find it. My apologies if it has been discussed before.

 

Long story short I'm finding files from one folder and moving it to another folder. To do that, I am using a formula to create the move command instruction that creates and runs a batch file. It works just fine. This is the command I am passing:

MOVE \\networklocation\OriginalFolder\*1234.* \\networklocationtarget\TargetFolder\Folder

 

The problem comes when I am trying to use an Analytic App (Wizard for old users). I am using an action tool linked to 2 user parameters from text boxes ID and FOLDER to change the string on the formula that creates the command.

Untitled.jpg

 

 

 

 

 

 

 

 

 

 

 

 

On the Action Tool I am using "Update Value with Formula":

"MOVE \\networklocation\OriginalFolder\*"+

tostring([ID])+

".*"+

"\\networklocationtarget\TargetFolder\"+

tostring([FOLDER])

 

  Updating Formula.jpgThe module runs live without problems, when it runs as yxwz and I put parameters on it, it blows with the error: Formula(3): Parse Error at char(0): Unknown variable "MOVE" (Expression#1).

Is like the formula doesn't recognize the quotes. I have tried with single quotes and double quotes. Have any of you faced issues with that before with the Formula within the Action tool acting up?

4 REPLIES 4
Claje
14 - Magnetar

Hi,

I think you're just missing some extra quotes

Here's a corrected formula for your action tool:

'"MOVE \\networklocation\OriginalFolder\*"'+

tostring([ID])+

'".*"'+

'"\\networklocationtarget\TargetFolder\"'+

tostring([FOLDER])

Basically, I added extra quotes around each of your string values as I believe these are causing you issues.

Note that if you run this and get an error that says "Unknown variable [ID]" that you probably need to add some quotation marks around the ID and Folder values

 

Something like:

+'"'+toString([ID])+'"'+
JArtNaranjo
7 - Meteor

Hi, 

Thank you for your reply, I appreciate it.

 

I tried the extra quotes as your first suggestion and I got:

There were Errors:
Formula (3): Parse Error at char (0): An operator must be between operands (Expression #1)

Sooooo I did the quotes around the variables and I got:

There were errors:
Formula (3): Parse Error at char (41): Parse Error (Expression #1)

The character 41 is the asterisk (*) on 

'"MOVE \\networklocation\OriginalFolder\*"'+

I need that * for the command statement... I'm losing my head at this point. I might change the whole approach and parse the command into pieces and have different actions for the variables and then join just to be able to modify the text string that I need on my batch file.

 

Any other ideas anyone?

patrick_digan
17 - Castor
17 - Castor

@JArtNaranjo I think this formula in your action tool (I'll call this method 1) should work

'"MOVE \\networklocation\OriginalFolder\*'+tostring([ID])+'.* \\networklocationtarget\TargetFolder\'+[Folder]+'"'

It would be more confusing if the folder the user enters had spaces (you would need to enclose the whole path in quotes).

 

For some different options, I've included the attached workflow which show 2 other ways to do this that appear simpler. You can connect your interface tools directly to the formula tool (Method 2) or you can you use the %Question.ToolName% syntax (method 3) and not connect anything. I'd be glad to expand upon these if they don't make sense or don't work when you try to translate to your use case.

 

To help you debug your situation, you may want to try the debugger. You need to show the interface designer (view >> interface designer) and then go to the second option which is the test view. You would enter some data and then click open debug. Then you would be able to more easily see exactly what is wrong with your formula tool. Note that method 3 doesn't work with the interface designer, but I use that method 99% of the time. The biggest benefit is that you can type in test values in the workflow configuration >> workflow panel and then run the app as a normal workflow (using the green and white triangle) and make sure it's working. Method 2 would also work this way. I only use Method 1 when necessary.

 

Capture.PNG

JArtNaranjo
7 - Meteor

Thank you so much @I really appreciate it. Not only did you help me and corrected my formula (Method 1), which worked by the way, but also provided other logic samples to solve the problem.

Can't thank you enough man. 

Labels