How to check from where a task is called?

  • Hi there,

    I have this MainTask(ActiveX or T-SQL) in a DTS-package, which can be arrived at from many different other tasks. Is there a way to check which previous task calls this MainTask?

    For example, I have Task1(ActiveX) and Task2(ExecuteSQL). Both have a workflow-arrow to MainTask. When MainTask is called from Task1: do this action. When called from Task2: the something else.

    At first I thought to use Global Variables, but I don't know how to 'set' a global variable in T-SQL.

    Any ideas are helpful.

    Greetz,
    Hans Brouwer

  • Most reliable way is to put another step in between the tasks writing an insert into a table, uniquely identifying each along with a date/time.

    That way, whichever route is taken you will be able to check a table.

    task1 - insert - call shared task

    task2 - insert - call shared task

    Alternatively, if you are logging the package you can check the log to see which steps were executed in each order.

    All of this assumes that you are calling the same step both routes performing identical actions. If not, then post back what you are trying to do depending on the route taken.


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Doesn't task3 wait for task1 and task2 to complete before execution?

    you can just connect them sequentially, if you're looking to find an error.

  • Correct. When you have two workflows going to the same task, Both workflows have to process before the connected task is performed. It is a logical AND operation.

  • Here's what you might want to do:

    Right-Click on Task1(ActiveX). Select Workflow->Workflow Properties. When that pops up, Select the Options tab. Check the "Use ActiveX script option". Then click the Properties Button. This will bring up an ActiveX screen.

    Copy and paste the code:

    Function Main()

    DTSGlobalVariables("[Global Variable Name]").Value = "Task1(ActiveX)"

    Main = DTSStepScriptResult_ExecuteTask

    End Function

    Change the Global Variable Name to a Global variable you have already created. Put this into every task's workflow that you want to track.

    What all of this does is before Task1, Task2, etc. is executed, this ActiveX script is executed. When you arrive at MainTask, you can check the global variable for the task name that it came from.

  • Thanks for the feedback all.

    Micheal, I think I will look-in to your suggestion. I have seen that construction bhefore and this would very well do the trick.

    Thanks again all.

    Greetz,
    Hans Brouwer

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply