Tuesday

Restricting large attachments in Quality Center

Once your Quality Center users discover that they can add attachments to defects (and test cases, and test sets etc etc), your storage requirements increase dramatically. Here is a neat way to prevent your users from attaching files over a certain size anywhere in Quality Center.

A client had a requirement to reduce the use of QC attachment storage as a lot of users are using up a lot of space unnecessarily. In one instance I found over 80GB of file space taken up with a 100MB file endlessly repeated. The attachment was on a “template” test and the users had duplicated it whenever they copied and pasted the “template”

I had to get this working today so investigated the attachment object and found it has some hooks so we could get it working quite simply.

The “Attachment” object available in the sub can give you access to the “CR_ENTITY” it is linked to. This gives us ALL the areas where a user can create an attachment. From there it was simply trial and error until I had the attachment record (attRec) described correctly for each “CR_ENTITY”.

The code goes directly into the QC workflow Common scripts area and replaces the existing Sub “Attachment_New”.


Sub Attachment_New(Attachment)   'Use ActiveModule and ActiveDialogName to get the current context.   On Error Resume Next       'Remove new attachment if file size is too big     If Attachment.Type = 1 then 'Attachment is of type TDATT_FILE - a file.        MaxFileSize = 3145728 'Set the maximum attachment size in Bytes <<- 3mb is our limit!        If Attachment.FileSize > MaxFileSize then           Select Case Attachment.Field("CR_ENTITY")                  'Requirement                  Case "REQ"                       Set attRec = ReqFactory.Item(Attachment.Field("CR_KEY_1"))                  'TestPlan                  Case "ALL_LISTS" 'Folder                       Set attRec = TreeManager.NodeByID(Attachment.Field("CR_KEY_1"))                       msgbox attRec.ID                  Case "TEST" ' Test                       Set attRec = TestFactory.Item(Attachment.Field("CR_KEY_1"))                  Case "DESSTEPS" 'Test step                       Set attTest = TestFactory.Item(Test_Fields("DS_TEST_ID").Value)                       Set attRec = attTest.DesignStepFactory.Item(Attachment.Field("CR_KEY_1"))                  'TestLab                  Case "CYCL_FOLD" 'Folder                       Set attRec = TestSetTreeManager.NodeById(Attachment.Field("CR_KEY_1"))                  Case "CYCLE" 'Test Set                       Set attRec = TestSetFactory.Item(Attachment.Field("CR_KEY_1"))                  Case "TESTCYCL" 'TestInstance                       Set attRec = TSTestFactory.Item(Attachment.Field("CR_KEY_1"))                  Case "RUN" 'Run                       Set attRec = RunFactory.Item(Attachment.Field("CR_KEY_1"))                  Case "STEP"  'Run Step                       Set attRun = RunFactory.Item(Step_Fields("ST_RUN_ID").Value)                       Set attRec = attRun.StepFactory.Item(Attachment.Field("CR_KEY_1"))                  'Defects                  Case "BUG"                       Set attRec = BugFactory.Item(Attachment.Field("CR_KEY_1"))           End Select           set AttFac = attRec.Attachments           Msgbox "Please exit this record and refresh the QC page. The file: " & vbLF & _                  Attachment.Name & vbLf & " has been removed as it exceeds the required file size of 3mb."           AttFac.RemoveItem(Attachment.ID)        End If     End If     On Error GoTo 0 End Sub



SOURCE : JDS Australia Website

Tip of the day : Finding a software Testing Job

here are many people who would like to get software testing jobs, but they are unsure about how to approach it. This may seem like a dream j...