Rational Clearquest - Clone Defect

Posted on 2007-10-16
Last Modified: 2010-04-21
Hi All,

I need hook code that that I can attach to a button that will clone a defect regardless of the state it is in and will create a new defect (not a child). I would like the code to be as simple as possible as I am not very good at coding.


Question by:jodonovan
    LVL 11

    Expert Comment

    VBScript isn't the right place for this.  You need to go to a perl forum.  Most of the hooks are done in cqperl.
    LVL 11

    Expert Comment

    Alternatively just google for cqperl.  Lots of examples of how to write hooks for ClearQuest.

    Author Comment

    As CQ accepts VB scripts I would prefer VB as I have no experience of perl
    LVL 11

    Expert Comment

    That's new.    All our scripts are written in perl.  I'll have to have a look at our CQ.  See if there is anything to switch it to VB.
    LVL 11

    Accepted Solution

    It will be something like this - all this script does is display a record

    option explicit

    dim session
    const dbname = "TestCQ", connname = "TestCQ"
    sub Include(filename)
       on Error Resume Next

       dim fileHandle, content, objFSO
       set objFSO = CreateObject ("FileSystemObject")
       if objFSO.FileExists(filename) then
          set fileHandle = objFSO.OpenTextFile (filename)
          content = fileHandle.ReadAll
          ExecuteGlobal content
       end if
       fileHandle = nothing
       objFSO = nothing
    End Sub

    sub CQLogin (login_name, password)
       dim dbDesc

       ' Connect via OLE to ClearQuest
       set session = CreateObject("CLEARQUEST.SESSION")
       if isNUll(session) then
          WScript.Echo "no session"
       end if

       session.UserLogon login_name, password, dbname, AD_SHARED_SESSION, connname

       WScript.Echo "Logged in as " & login_name
    end sub
    sub CQShowRec (irnum)
       dim irrec, irstr
       dim fieldNameList, fieldName, fieldInfoObj, fieldType, fieldValue
       irstr = dbname & right ("00000000" & cstr(irnum), 8)
       set irrec = session.GetEntity ("Report", irstr)

       fieldNameList = irrec.GetFieldNames
       for each fieldName in fieldNameList
          set fieldInfoObj = irrec.GetFieldValue(fieldName)
          fieldType = fieldInfoObj.GetType
          fieldValue = fieldInfoObj.GetValue      
          WScript.echo _
             "Name=" & fieldName &_
             "  Type=" & fieldType & _
             "  value=" & fieldValue
          if fieldName = "corrective_action" then
             CQShowFiles irnum
          end if
    end sub
    sub CQShowFiles (irnum)
       dim irrec, irstr
       dim fieldInfoObj
       dim fileInfo, fileRec, fileRecList, fileStrList
       dim filePath, fileName, fileFrom, fileTo, fileVerify, fileChecker

       WScript.Echo "Listing all the files in ir " & irnum

       irstr = dbname & right ("00000000" & cstr(irnum), 8)
       set irrec = session.GetEntity ("Report", irstr)

       set fieldInfoObj = irrec.GetFieldValue ("corrective_action")
       fileStrList = fieldInfoObj.GetValue
       fileRecList = split (fileStrList, chr(10))
       for each fileRec in fileRecList
          set fileInfo = session.GetEntity ("clearcase_file", fileRec)
          filePath = fileInfo.GetFieldValue ("path").GetValue
          fileName = fileInfo.GetFieldValue ("name").GetValue
          fileFrom = fileInfo.GetFieldValue ("from_issue").GetValue
          fileTo   = fileInfo.GetFieldValue ("to_issue").GetValue
          fileVerify = fileInfo.GetFieldValue ("verification_method").GetValue
          fileChecker = fileInfo.GetFieldValue ("checked_by").GetValue
          WScript.Echo _
             fileName &_
             " From=" & fileFrom &_
             " To=" & fileTo &_
             " Verification=" & fileVerify &_
             " Verifier=" & fileChecker

    end sub
    sub CQCloneRec (irnum)
       WScript.echo "No idea how this is done"
    end sub

    Include "C:\Program Files\Rational\ClearQuest\clearquest.bas"
    CQLogin "cup", "cup"
    CQShowRec 123
    CQCloneRec 123
    LVL 11

    Expert Comment

    I can't experiment on our DB because it is live and I have to give reasons why I've created a new record.  It looks like you need to duplicate the whole record and commit it.  I don't know if there is an easy way of doing this.  I've never found anything on relational databases simple.

    Author Closing Comment

    I haven't had an opportunity to test your code but it definitely points me in the right direction. Thanks

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
    This script will sweep a range of IP addresses (class c only, and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now