How to Exit a For Loop in MoveIt

659 views Asked by At

I am setting up my first real task using Moveit as we just purchased it to replace a home-grown file mover.

I am running a for loop that will pick up 24 files but if one fails, it currently continues on and picks up the rest. If the final file succeeds (even if previous files failed), the error code = 0 and it sends the success email message to the client. What I want is for the for each loop to end if one file fails and then the error code != 0 and the error email will be sent instead. I can put the error email in the for loop and send that but I don't want the success message to send until all 24 files have been copied and the client only wants one success message rather than one for each file.

But I can't figure out how to make the for loop end or, alternatively, to accumulate the error codes so that I can check to see if the value of the sum is greater than 0 to determine which email to send.

I've tried the manual and can't figure it out, I think I need to use a script (MOVE it uses vbscript) but again I can't figure out how to write one that does what I need. I have tried Google but can't find any good examples of scripting for tasks we want to do in Moveit and I don't know vbscript at all.

2

There are 2 answers

3
Ekkehard.Horner On

Use Exit For (surprise!) to exit a For loop. Use Boolean Operators to accumulate True/False|Success/Failure values.

0
Richard Auger On

This is an advanced task that you are talking about. First, all of the files are downloaded prior to entering the loop. You cannot stop downloading... The logic will kick in after the files are downloaded.

You cannot exit the loop, but you can stop further actions. It sounds like you have an if block checking "File Error Code" which will just tell you the result of the last file process/upload. You can embed a second if statement to also check "Task Error Code" to action based on overall success/failure.

From my experience however I would recommend to use a couple of traditional tasks with conditional (success/failure) next actions...download one file at a time (via advanced options - download limits) and repetitively call the same task. You can also pass a parameter between the tasks containing the current number of files transferred.