Check mandatory fields for a defect , update with valid values before upload. (1792 Views)
Reply
Frequent Collector
RMenon
Posts: 4
Registered: ‎05-07-2013
Message 1 of 7 (1,792 Views)
Accepted Solution

Check mandatory fields for a defect , update with valid values before upload.

[ Edited ]

My scenario is to ensure all mandatory fields for a defect is known to me before i update defect details and upload it to the QC.

 

Below is the code by which i am gettting the mandatory fields count

 

 '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    Dim i As Integer
    Dim j As Integer

    Dim bugFact As BugFactory
    Dim bugList As List
    Dim theBug As Bug

     
    Dim fCust As Customization
    Dim fCustFields As CustomizationFields
    Dim fCustField As CustomizationField


'm_server is tdc connection object
    Set bugFact = m_server.BugFactory
    Set bugList = bugFact.NewList("")
    m_server.IgnoreHtmlFormat = True

    Set fCust = m_server.Customization
    Set fCustFields = fCust.Fields


   Cnt = 0
   For Each fCustField In fCustFields.Fields("BUG")
  
    If fCustField.IsRequired = True Then
     Cnt = Cnt + 1
    End If
   Next
  
   MsgBox Cnt
   

 '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 

Output is 4. (Which is not as expected)

 

If i manually check the manadatory fields by checking how many fields have " * " prefixed in QC for an existing defect. I get 26 fields which need to have a mandatory value.

 

Need suggestions here if there is any error in my code or some new ways to get the required details which are marked with ' * '.

 

Attached screenshot having a defect details window.

NOTE: i am using HP QC 9.2

Honored Contributor
Jan Czajkowski
Posts: 2,114
Registered: ‎12-12-2007
Message 2 of 7 (1,768 Views)

Re: Check mandatory fields for a defect , update with valid values before upload.

"IsRequired" corresponds to a property value of the CustomizationField object in the API and a column in the database. That is what you get with your script - the fields that have the Required option set from Project Entities in Customize.

 

But you can also make a field required or not required from the workflow. Then you are not changing the properties of the object as such. Your script code won't have any knowledge of the workflow layer.

 

So there is no reliable way of doing what you want from the outside of QC.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Frequent Collector
RMenon
Posts: 4
Registered: ‎05-07-2013
Message 3 of 7 (1,763 Views)

Re: Check mandatory fields for a defect , update with valid values before upload.

Thanks for the reply!

 

So, from what i get from your reply, you mean that i can get the mandatory fields which are set for the particular table from workflow but not from the customize object?

 

I have limited knowledge on workflow? Is this a hidden layer which cannot be seen in QC? Is the layer triggered during runtime whenever any event let's say when we clcik on a new defect, the fields permissions are first updated using workflow and later displayed accordingly to the user ?

Honored Contributor
Jan Czajkowski
Posts: 2,114
Registered: ‎12-12-2007
Message 4 of 7 (1,734 Views)

Re: Check mandatory fields for a defect , update with valid values before upload.

The workflow only executes in response to user interaction. It has no impact when using the API - except when you are using API functionality from within the workflow.

 

So for example the property of a field of being required depends first on the customization settings, registered in the SF_IS_REQUIRED column in the SYSTEM_FIELD table. When working via the API, this is the only aspect that is known.

 

But when the user logs in interactively via the GUI, you also have to take the workflow into account. Here you can override the DB settings - for example making a certain field conditionally required based on the value of another field, like the defect Status field, or making it required for a certain user group only.

 

So from the workflow you can at each moment display which fields are mandatory for the current user. But unless you blocked project administrator access to the workflow and made sure no requiredness settings are ever modified there, you can never be sure you get the full picture when working from the outside using the API.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Frequent Collector
RMenon
Posts: 4
Registered: ‎05-07-2013
Message 5 of 7 (1,718 Views)

Re: Check mandatory fields for a defect , update with valid values before upload.

Thanks for the information.

 

Unfortunately i do not have project administrator access . To start with i wanted to check out some examples for workflow object but not able to find any code which shows how to initialize workflow objects and use them.

 

Please share if you have any code related to it which can work without administrator access.

 

Thanks in advance.

 

 

Visitor
Javasaigon
Posts: 3
Registered: ‎01-27-2014
Message 6 of 7 (1,448 Views)

Re: Check mandatory fields for a defect , update with valid values before upload.

Hi,

 

Need help to customize one field in defect. In the defect there is one field called  "Root Cause" (BG_USER_06) , this field is currently not mandatory. However, I would like to customize this field will be come "mandatory" field whent the developer update the status of defect to 'Fixed" (BG_STATUS).

 

Would you please assist how to modify the code in the "Workflow" / ScriptEditor . Your input is highly appreciate.

 

 

  

Trusted Contributor
Tom_Janouskovec
Posts: 105
Registered: ‎12-21-2011
Message 7 of 7 (1,422 Views)

Re: Check mandatory fields for a defect , update with valid values before upload.

Hi Javasaigon.

 

There is your code:

Sub Bug_FieldChange(FieldName)
  On Error Resume Next
  If FieldName = "BG_STATUS" then
    if Bug_Fields.Field("BG_STATUS").Value = "Fixed" then
       Bug_Fields.Field("BG_USER_06").IsRequired = true
    else
       Bug_Fields.Field("BG_USER_06").IsRequired = false
    end if
  end if
  On Error GoTo 0
End Sub

 Br, Tomas

[If my advice solves your issue or query, please mark the thread as solved. Clicking on KUDOS star is the best way how to say thank you.]
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.