Taskset.InUse

Syntax Parameters Return Value
- - Boolean

SVB Example

Data Entry Example 8: Adding a taskset:

Sub Main

    'The following example assumes that you have MAS licensed.

    Dim oOM As ObjectManager
    'Reconnect into Enterprise
    Set oOM = New ObjectManager
    oOM.Reconnect Application

    Dim taskInfo As New TasksetCreateInfo
    taskInfo.AuditLogReason = "Creating bread task"
    taskInfo.Folder = "/Blake's Materials"
    taskInfo.Name = "Bread Review"

    'Add the taskset.
    Dim breadTask As Taskset
    Set breadTask = oOM.Tasksets.AddEx(taskInfo)
    breadTask.AutoSave = False

    'Add a description
    breadTask.Description = "Review of bread-mixture ingredients"

    'If a task execution fails, then stop the task.
    breadTask.Options.TaskErrorExecutionAction = swcStop
    'Schedule it turn run every day at 6:00PM ("18").
    'Refer to TasksetScheduleInfo.ScheduleString for an explanation of this syntax.
    breadTask.ScheduleInfo.ScheduleString = "0 18 * * *"
    'Enable the taskset
    breadTask.InUse = True

    'Connect our QC analysis to the taskset.
    Dim qcTask As QCMonitorTask
    Set qcTask = breadTask.Tasks.AddQCMonitorTask(1)
    qcTask.Monitor = oOM.Monitors("/Blake's Materials/Bread Charts")
    'Specify that we will watch the grain level characteristic in this task.
    qcTask.CharacteristicReturnCodesCollection.Add(oOM.Characteristics.Item("/Blake's Materials/Grain Level"))

    'Add a rule to send an email if the grain level characteristic has an alarm.
    Dim taskRule As TasksetRule
    Set taskRule = breadTask.Rules.Add("Email Notify")
    Dim condition As TasksetCondition
    Set condition = taskRule.Conditions.Add()
    condition.Task = qcTask
    condition.Characteristic = oOM.Characteristics("/Blake's Materials/Grain Level")
    'This assumes that you have the mail notification settings configured.
    taskRule.Actions.AddSendMailAction().AddRecipient("admin@acmebakery.com")

    'Set the permissions to be the same as the QC analysis
    For i = 1 To qcTask.Monitor.AccessControlList.Count
        Set permissionItem = qcTask.Monitor.AccessControlList.Item(i)
        If permissionItem.IsUser Then
            breadTask.AccessControlList.AddUser(permissionItem.Name, permissionItem.CanEdit)
        Else
            breadTask.AccessControlList.AddGroup(permissionItem.Name, permissionItem.CanEdit)
        End If
    Next

    'commit our settings
    Dim updateInfo As New TasksetUpdateInfo
    updateInfo.AuditLogReason = "Setting up bread review taskset"
    breadTask.SaveEx(updateInfo)

    oOM.Disconnect

End Sub