使用VBScript在QC(HP Quality Center)中启用历史记录字段

时间:2014-02-04 10:52:04

标签: vbscript customization qc hp-quality-center

我正在尝试使用VBS在QC11的自定义部分中激活项目的History标志。这是我的剧本:

If Not voCustomization.IsLocked Then

' lock
voCustomization.LockObject
Print "[" & Sysdate() & "] Locked customization object."

If Err.Number = 0 Then

    Set custFields = voCustomization.Fields

    ' Make field searchable
    Set fcraField = custFields.Field("Test", "TS_USER_88")
    If fcraField.IsSupportsHistory Then
        If fcraField.IsHistory Then
            Print "[" & Sysdate() & "] History already set on TS_USER_88 of " & vsDomain & "." & vsProject
        Else
            fcraField.IsHistory = True
            Print "[" & Sysdate() & "] History enabled on TS_USER_88 of " & vsDomain & "." & vsProject
        End If
    End If

    ' check if the customization object has changed and commit if neccessary
    If voCustomization.IsChanged Then
        Print "[" & Sysdate() & "] Uncommited changes are waiting."
        voCustomization.Commit
        Print "[" & Sysdate() & "] Successfully commited change"
    Else
        Print "[" & Sysdate() & "] No uncommited changes are pending."
    End If

Else
    Print "[" & Sysdate() & "] Could not lock project " & vsDomain & "." & vsProject & ", abording now..."
End If 'voTDC.Customization.LockObject

' unlock
voCustomization.UnLockObject
Print "[" & Sysdate() & "] Unlocked customization object."

当我检查脚本的输出时,我可以看到它已成功连接到项目并说“历史已经设置...”。当我进入customization section > Project Entities > Test > User Fields > TS_USER_88时,不会选中“历史记录”复选框。我做错了什么?

1 个答案:

答案 0 :(得分:0)

If custFields.FieldExists("TEST", "TS_USER_88") Then

    Set field = custFields.Field("TEST", "TS_USER_88")

    If field.IsSupportsHistory Then
         If field.IsHistory Then
                         Print "[" & Sysdate() & "] History Flag already enabled on TS_USER_88, performing no changes."
         Else
                         field.IsHistory = True
                         Print "[" & Sysdate() & "] Successfully enabled history field of TS_USER_88."

                         'Commit changes to database
                         cust.Commit()
                         Print "[" & Sysdate() & "] Changes committed to DB"
         End If
    Else
        Print "[" & Sysdate() & "] FAILED to enable hisotry field of TS_USER_88."
    End If

    Else
    Print "[" & Sysdate() & "] Project can NOT be migrated..."
    Print "[" & Sysdate() & "] FIELD TS_USER_88 NOT FOUND - PROJECT IS NOT SUPPORTED."
End If