locked
For each loop container RRS feed

  • Question

  • Hi,

    I am using For each loop container and I have another sequence container inside the for each loop container. I want to execute the for each loop container for each iteration even if sequence container inside it fails.


    Aniruddha http://aniruddhathengadi.blogspot.com/

    Friday, June 15, 2012 8:50 AM

Answers

  • When you made a test, please remove the MessageBox.show(), it will block process sometime. You can loop a set of files, and didn't nothing just use random number to set Success or Failure in scripts.

    Result shows success in last loop.

    Result shows error in last loop.


    Please vote if it's helpful and mark it as an answer!

    Friday, June 15, 2012 9:46 AM

All replies

  • Hi,

    You need to configure the ON ERROR handler and system variable.

     -

    For example, there're two foreach loop container, the inner foreach container has a script task with codes inside -

     public void Main()
            {
               
                int num = new Random().Next(10);
    
                MessageBox.Show(Convert.ToString(num));
    
                if (num < 5)
                {
                    // TODO: Add your code here
                    Dts.TaskResult = (int)ScriptResults.Failure;
                }
            }
    

    If random number < 5, then this scrip task will be failure.

    So click the inside script task and open its event handler 'ON ERROR', then set its package system variable (Propagate) to false.


    Please vote if it's helpful and mark it as an answer!

    Friday, June 15, 2012 9:35 AM
  • If inside script task (Or execute sql task/File System Task/Send Email Task) get an error in a loop, the system will ignore its failure then goes into next loop.

    1. Open Event handler for component

    2. Set its system variable Propagate to 'False'.


    Please vote if it's helpful and mark it as an answer!

    Friday, June 15, 2012 9:37 AM
  • When you made a test, please remove the MessageBox.show(), it will block process sometime. You can loop a set of files, and didn't nothing just use random number to set Success or Failure in scripts.

    Result shows success in last loop.

    Result shows error in last loop.


    Please vote if it's helpful and mark it as an answer!

    Friday, June 15, 2012 9:46 AM