Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Task Instance Details - SDK Not very useful

Created: 15 Feb 2013 | 4 comments

I have a workflow that schedules our computer build jobs. I now want to add a PCT step in there. Since I have to wait for the PCT Capture and Image deployment jobs to finish before starting the PCT Deploy task, I need to figure out when a job is finished. Currently the Schedule Task API doesn't return the task instance once a task is scheduled. Which is a big PITA. So I have to hunt through the task tables to find the most current running task and match it to the job I scheduled. I think I found the correct tables for this though I can't quite figure out how to link the JOB to the TASK instance.

However... the absolute ideal solution would be to be able to get all the data that is showed in the "Task Instance Details" screen in the console when you drill down to a computer to find out what step it's on. Does anyone know what tables this data is coming from?

In the workflow I know the GUID of the Job, and the GUID of the Computer. What I need is the TaskInstance of the job, what step in the job the computer is currently doing, how many steps are left, and if those steps were successful or not for the subtasks and the overall Job.

Comments 4 CommentsJump to latest comment

wenhamp's picture

Did you ever work this out, I started looking through the tables yesterday and have yet to find what I (we) are looking for.

b3tts32's picture

Are you using 6.9 or 7.1? We're doing something similar with workflow and ds 6.9. I'm using the wait on external event component to check when the job is completed via a sql stored procedure then continue with the rest of the job. Once completed it notifies the user. 

We've simply broken the jobs down into separate tasks then piece it together with workflow as follows..

Select OS/Office Version > Change BIOS > Capture Ghost Hot Backup (adding for XP to 7 migration) > Capture Personality > Image Computer > Deploy Personality > (option to restore ghost image if something goes wrong) > Completed

SaschaH's picture

I once build a report to check for run tasks, maybe the sql can help you find what you need, if you start the task by workflow you can give it specific run name. Maybe that way you can add some number sequence and find the right ones. Hope it pushes you in the right direction.

select distinct
     vc.Name,
     it.Name as Task,
     eti.Result,
     eti.Success,
     eti.EndTime
        
from Evt_Task_Instances eti

join  ItemVersions iv
     on eti.TaskVersionGuid = iv.VersionGuid
join vItem it
     on it.Guid = iv.ItemGuid
join vComputer vc
     on vc.Guid = eti._ResourceGuid
join dbo.CollectionMembership cm
     on vc.Guid = cm.ResourceGuid

where
     eti.InstanceType = 'Client'
     and vc.name <> ''
     and eti.EndTime is not null
     and eti.EndTime > GETDATE()-2
     and it.Name like '%%TaskName%%'

order by
     vc.Name,
     it.Name

Bechtle – your strong IT partner. Today and tomorrow

If that seems to help, please "Mark as Solution"

wenhamp's picture

Using 7.1

I came up with 3 queries that will get different information. The below assumes you are starting the Altiris Job via Workflow as this gives you access to the Exposed Altiris Task Run Instance GUID.

-- This gets the Job summary info

SELECT TaskName, StartTime, EndTime, Result, InstanceStatus, Success, TaskInstanceGuid, ParentTaskInstanceGuid

FROM Evt_Task_Instances

WHERE TaskInstanceGuid = @ExposedAltirisTaskGuid

-- This gets the Job instance summarie(s)

SELECT it.Name, eti.StartTime, eti.EndTime, eti.Result, eti.InstanceStatus, eti.Success, TaskInstanceGuid, ParentTaskInstanceGuid

FROM Evt_Task_Instances AS eti

INNER JOIN ItemVersions AS iv ON eti.TaskVersionGuid = iv.VersionGuid

INNER JOIN Item AS it ON iv.ItemGuid = it.Guid

WHERE eti.ParentTaskInstanceGuid = @ExposedAltirisTaskGuid

ORDER BY StartTime

-- And finally, this gets the individual job steps and their results from the Job instance.

SELECT it.Name, eti.StartTime, eti.EndTime, eti.Result, eti.InstanceStatus, eti.Success, TaskInstanceGuid, ParentTaskInstanceGuid

FROM Evt_Task_Instances AS eti

INNER JOIN ItemVersions AS iv ON eti.TaskVersionGuid = iv.VersionGuid

INNER JOIN Item AS it ON iv.ItemGuid = it.Guid

WHERE eti.ParentTaskInstanceGuid = (SELECT TaskInstanceGuid FROM Evt_Task_Instances WHERE ParentTaskInstanceGuid = @ExposedAltirisTaskGuid )

If your workflow applies Altiris jobs to multiple resources at once, you'll have to add the resourceguid to the where clause (eti._ResourceGuid in my example)