Re: QC 11 Workflow Issue (352 Views)
Reply
Occasional Advisor
thick client testing
Posts: 20
Registered: ‎11-15-2009
Message 1 of 5 (391 Views)
Accepted Solution

QC 11 Workflow Issue

I have a workflow in QC 11 which is working fine when i am logging as TD Admin role,However when i am logging as Project Manager or Tester(or any other role),The workflow is not working.

 

For ex when logging as TD Admin role i am able to change the Bug Status from New to Assign Developer(or any other valid state)

 

but when logging as Project Manger each time  i am trying to change the value i am getting a msgbox-The initial value will be set to New, which ideally should notcome according to the workflow.

 

 

Can anyone help me regarding this.

Honored Contributor
Jan Czajkowski
Posts: 2,111
Registered: ‎12-12-2007
Message 2 of 5 (376 Views)

Re: QC 11 Workflow Issue

First thing to check is if there are any transition rules defined for the groups for the Bug Status field.

 

If not, you need to check the workflow code carefully, especially Bug_FieldCanChange.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Occasional Advisor
thick client testing
Posts: 20
Registered: ‎11-15-2009
Message 3 of 5 (352 Views)

Re: QC 11 Workflow Issue

[ Edited ]

I checked for what you have asked, but couldn't find the error.

 

 

 

the issue is i guess the value in the bug status filed is not being read and everytime QC is taking the status as blank, that's why i am getting the msgbox:The initial value will be set to new.

 

Here is the code for Bug field can change and Last value function(it returns the last value stored in BUG Status Field)

 

Function Bug_FieldCanChange(FieldName, NewValue)
  On Error Resume Next
    Dim fieldPrevValue:fieldPrevValue = LastValue("BG_STATUS", "Defects")
    
    Bug_FieldCanChange = True
    If FieldName = "BG_STATUS" then
      select CASE fieldPrevValue
        case ""
          select case NewValue
           case "New"
           case else
             Bug_FieldCanChange = False
             MsgBox "The initial value will be set to 'New'"
             NewValue = fieldPrevValue
             Bug_Fields("BG_STATUS").Value = "New"
          end select

 

 

Function LastValue(FieldName, Entity)
         'This function returns the value of the field before the user changes it.
         'FieldName - Name of field for which you are looking
         'Entity - Name of the Entity affected
         On Error Resume Next

         dim com
         dim rec
         dim td

         'If the Entity is a Defect entity
         if Entity = "Defects" then
            'If the bug is new then the previous value is Null
            if Bug_Fields("BG_BUG_ID").IsNull then
               LastValue =""
               exit function
            end if
         end if

         set td = TDConnection
         set com = td.Command

         'Run SQL query to return the previous value
         select case Entity

            case "Requirements"
               com.CommandText = "select " & FieldName & " from REQ where RQ_REQ_ID=" & Req_Fields("RQ_REQ_ID").Value
            case "Test"
               com.CommandText = "select " & FieldName & " from TEST where TS_TEST_ID=" & Test_Fields("TS_TEST_ID").Value
            case "Design Steps"
               com.CommandText = "select " & FieldName & " from DESSTEPS where DS_TEST_ID=" & DesignStep_Fields("DS_TEST_ID").Value & _
            " and DS_STEP_ID=" & DesignStep_Fields("DS_STEP_ID").Value
            case "Test Set"
               com.CommandText = "select " & FieldName & " from CYCLE where CY_CYCLE_ID=" & TestSet_Fields("CY_CYCLE_ID").Value
            case "Test in Test Set"
               com.CommandText = "select " & FieldName & " from TESTCYCL where TC_CYCLE_ID=" & TestSetTest_Fields("TC_CYCLE_ID").Value & _
            " and TC_TEST_ID=" & TestSetTest_Fields("TC_TEST_ID").Value & _
            " and TC_TEST_INSTANCE=" & TestSetTest_Fields("TC_TEST_INSTANCE").Value
            case "Run"
               com.CommandText = "select " & FieldName & " from RUN where RN_RUN_ID=" & Run_Fields("RN_RUN_ID").Value
             case "Steps"
                com.CommandText = "select " & FieldName & " from STEP where ST_RUN_ID=" & Step_Fields("ST_RUN_ID").Value & _
            " and ST_STEP_ID=" & Step_Fields("ST_STEP_ID").Value
            case "Defects"
               com.CommandText = "select " & FieldName & " from BUG where BG_BUG_ID=" & Bug_Fields("BG_BUG_ID").Value

         end select

         set rec = com.Execute
         rec.First

         LastValue = rec.FieldValue(Cstr(FieldName))
         set com = nothing
         set rec = nothing

         On Error GoTo 0

End Function

 

 

 

can you please look into it?

Honored Contributor
Jan Czajkowski
Posts: 2,111
Registered: ‎12-12-2007
Message 4 of 5 (346 Views)

Re: QC 11 Workflow Issue

First - you don't ever need the LastValue function. It will only lead to extra database accesses.

 

You can get the current (= last) value by accessing the field directly:

   fieldPrevValue = Bug_Fields("BG_BUG_ID").Value

 

That is the significance of a FieldCanChange function. It executes before the field value is changed. The value you are trying to change to is the NewValue parameter to the function. If you return True from the function the the NewValue will be accepted. Otherwise you return False, and the field never changes its value.

 

What your select block

          select case NewValue
           case "New"
           case else
             Bug_FieldCanChange = False
             MsgBox "The initial value will be set to 'New'"
             NewValue = fieldPrevValue
             Bug_Fields("BG_STATUS").Value = "New"
          end select

 

is saying is that if you try to set the status field to anything else than New, the change will be refused. So as far as I can see, the result of your code is exactly what you described, so it is working all right.

 

So the problem now is to decide what you really want to accomplish. Then we can discuss how to do it.

 

 

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Occasional Advisor
thick client testing
Posts: 20
Registered: ‎11-15-2009
Message 5 of 5 (331 Views)

Re: QC 11 Workflow Issue

Thanks for your response...after passing the value of bug status in FieldPrev value  instaed of using LAST Value function...

It's working now...

 

THANX A LOT.......

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.