[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Rational Clearquest - Clone Defect

Posted on 2007-10-16
8
Medium Priority
?
4,729 Views
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.

Regards,

Joe
0
Comment
Question by:jodonovan
  • 5
  • 2
7 Comments
 
LVL 11

Expert Comment

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

Expert Comment

by:cup
ID: 20084757
Alternatively just google for cqperl.  Lots of examples of how to write hooks for ClearQuest.
0
 

Author Comment

by:jodonovan
ID: 20146311
As CQ accepts VB scripts I would prefer VB as I have no experience of perl
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Expert Comment

by:cup
ID: 20149309
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.
0
 
LVL 11

Accepted Solution

by:
cup earned 750 total points
ID: 20155987
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
      fileHandle.Close
      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"
      WScript.Quit
   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
   next
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
   next

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
0
 
LVL 11

Expert Comment

by:cup
ID: 20165953
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.
0
 

Author Closing Comment

by:jodonovan
ID: 31408185
I haven't had an opportunity to test your code but it definitely points me in the right direction. Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

872 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