Foreach Loop Container and Dts.TaskResult


  • Hi.

    So I have a Foreach Loop Container, and in it, a Script Task. On success of Script Task it follows to a TSQL Query, if Script Task fails, the flow goes to another TSQL Query. Green arrow or Red.

    However in the Script Task I have setup a try {} catch {} condition that does a bit of logging and then issues a Dts.TaskResult = (int)ScriptResults.Failure. I find that line breaks the foreach loop even if the Flag FailParentOnFailure is set to False.

    I wanted the Failure or Sucess of the Script Task to only control the flow inside the Foreach Loop, not to break it. I am thinking this wrong ?

    Wednesday, September 11, 2013 12:38 AM


All replies

  • Did you set MaximumErrorCount property appropriately?



    Wednesday, September 11, 2013 12:42 AM
  • Hi Nuno

    You need to set the "ForceExecutionResult" for Foreach Loop Container to "Success".

    Regards Harsh

    Wednesday, September 11, 2013 4:42 AM
  • Hello everyone. Sorry for not answering this sooner as I needed extra time to test your suggestions and making sure I wasn't following them through.

    Reza. I'm sure I understand your suggestion. If I set the inner Script Task MaximumErrorCount to 99 or to 0 (infinity) it still breaks the Foreach Loop Container at the first Go. if I set the outer Foreach Loop MaximumErrorCount to 0 and the following TSQL Queries find a Error then great havoc can arise from that.

    Harsh, the values for ForceExecutionResult for Foreach Loop Container are True or False at the properties panel.
    Is it possible to check that from within the Script Task ? If this is what you mean, I tried to search how to and just confused myself. Could you elaborate ?

    Thursday, September 26, 2013 6:40 PM