I need a way to Limit File Attachment Size in Quality Center
Question ID: 104056
1
0

I suppose this can be done in the workflow, does anyone have code to limit the filesize of attachments in Quality Center?

Marked as spam
Posted by (Questions: 36, Answers: 3)
Asked on March 11, 2010 4:21 pm
14 views
Answers (3)
4
Private answer

The only optiojn is to programmatically set the limit, launch the script workflow editor, and add the following code as the first line under the Defect Module:

    **'---Limit Attachment Size
    Dim MaxFileSize 'Global Variable to hold max file size
    MaxFileSize = 6000 'Set the maximum attachment size in Bytes
    Dim Bugid 'Global Variable to hold Requirement ID*****

Then you'll need to create a subroutine (Just add this code to the bottom of the Defect module if there are other subroutines:

Sub Defects_Attachment_New(Attachment) 
On Error Resume Next

if Attachment.Type = 1 then 'Attachement is of type TDATT_FILE - a file.
    if Attachment.FileSize > MaxFileSize then

       Dim tdc
       Dim BugF, AttF
       Dim Cmd, rs
       Dim Text
       Dim bug, attid

       set tdc=TDConnection
       set BugF = tdc.BugFactory ' this section gets the list of Attachments
       set bug = BugF.Item(Bugid) ' for the current Defect.
       set AttF = bug.attachments
       Text = ''SELECT * FROM CROS_REF WHERE CR_REFERENCE = '''&Attachment.name&'''''
       set cmd = tdc.Command 'Create an SQL Command object
       Cmd.CommandText = Text
       set rs = Cmd.Execute 'Create a recordset of the current attachment

       if rs.RecordCount > 0 then 'Ensure that the command returned a result
         rs.first 'Get to the start of the recordset
         attid = rs.FieldValue(2) 'Get the ID of the attachment (field 2 = CR_REF_ID)
         AttF.RemoveItem(attid) 'Remove the Attachment from the Factory
         MsgBox ''This Attachment is too large. You can only upload files smaller     than ''&MaxFileSize&'' Bytes''
         MsgBox ''The attachment has not been uploaded.''
      else
         msgbox ''An error has occured. Please try again.''
      end if
    end if
end If
On Error GoTo 0
End Sub

Lastly, we need to add the following code to the Bug_MoveTo subroutine:

Sub Bug_MoveTo
    Fields = Bug_Fields
    Bugid = Fields(''BG_BUG_ID'').Value 'Set the global variable holding entity's id
    msgbox(''Bugid = ''& Bugid)
End Sub

Marked as spam
Posted by (Questions: 2, Answers: 477)
Answered on March 11, 2010 6:00 pm
1
Private answer

Wrong.. ATTACH_MAX_SIZE does NOT limit the size of an attachment. It only limits how big of an attachment to include in an email the QC server sends.

HP has NO WAY to limit the size of an attachment (even in QC10). You can write code such as that above, but it only works whan adding an attachment to an existing defect. IT DOES NOT WORK if you are adding an attachment while adding a new defect. This is because HP does not run the Defects_Attachment_New function during the add a new defect.

HP know about this, but has yet been able to fix it.

Marked as spam
Posted by (Questions: 0, Answers: 3)
Answered on November 1, 2010 9:27 pm
0
See the answer by Captain Mercury. In later versions a SiteConfiguration parameter was added for this. UPLOAD_ATTACH_MAX_SIZE.
( at April 30, 2015 7:58 pm)
0
Private answer

In QC/ALM 11.x, 11.5x and 12.x there is a parameter called UPLOAD_ATTACH_MAX_SIZE. This parameter prevents the upload of attachments whose size is greater than the integer value specified for this parameter. The size is in kilobytes. Note: This parameter does not affect uploads of attachments in integration tools. The default value is -1 (meaning, all attachments are uploaded regardless of size).

Example: Set it to 600 to limit the attachment size to 600KB.

https://softwaresupport.hp.com/group/softwaresupport/search-result/-/facetsearch/document/KM01286335

Marked as spam
Posted by (Questions: 6, Answers: 167)
Answered on April 30, 2015 7:56 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top