Hello @Swapneel Hosur ,
Thanks for the question and using MS Q&A platform.
As I understand you are having trouble capturing the error message of an activity inside switch, from an activity outside switch.
What I recommend is placing a Set Variable inside each of the switch cases to record the error, so you can refer to it outside the switch. Pipeline variables have a single 'scope', meaning no matter where in the pipeline you are, there is only one instance of the variable. Set Variables inside loops point to the same place Set Variables outside loops do.
I'm not practiced with SSIS, but from what I read, I don't think "Delay Validation" is an option in pipelines, beyond the ?..
You will get this same "The output of the activity can't be referenced since it is either not an ancestor to the current activity or does not exist" when you try to reference an activity inside ForEach, Until, If activities. I'll explain the ForEach and Until cases.
In a loop, the same activities are run multiple times. As they are the same, they have the same names. Since they have the same names, you can't specify which instance. Thus referencing inner activities is disallowed.
Now you might note, "Activities in different cases are required to have different names, and Switch only runs once. Why can't we reference these?"
I'm not sure, but I suspect it is related to that concept of "Delay Validation". When an activity is NOT run, it is given the status "Skipped". However, I noticed this does not apply to inner activities of the not-run cases. I tested by linking a Fail activity to a Wait activity by a skip-dependency, and ran the other branch.
Since this activity was not run in the inactive branch, it probably doesn't exist in any way.
The "ancestor to the current activity" means a direct lineage of activities connected by dependencies is required. This is because dependencies establish the order in which activites are executed. Without this, you might try to get the output of Lookup before it completes, or get a variable before it is set. The ability to reference an activity is linked to the dependency chain. The inner activities do not have a dependency linking to the outer.
Now you might ask "why can't we make an exception here? The inner activities belong to the switch, and I have dependency on the switch."
I don't know. I'd have to ask the developers. Maybe it is possible with a feature request. Maybe the back-end architecture precludes it. My hunch is that each inner section is run on a separate compute context.
Please do let me if you have any queries.
Thanks
Martin
- Please don't forget to click on
or upvote
button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how - Want a reminder to come back and check responses? Here is how to subscribe to a notification
- If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators