This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ALM workflow to send email on check in of each test

I have created a workflow script which will send an email to specified recipients "After Check In" of a test if specific conditions are met.

My script is triggered by the TestPlan_ActionExecuted event and is checking for an ActionName of either the act_vcs_checkin ActionName (which is triggered when checked in using the normal check in directly from the toolbar) or the PendingCommandList.Pending.CheckIn ActionName (which is triggered when checked in from the "Pending Check In" dialog).

The script executes as expected when a single test is checked in.

In all the testing I have run -  if multiple tests are checked in together (via either selecting multiple tests, then Check in or via "Pending Check In" dialog box accessible from the top right of the Test Plan toolbar) the script only executes once and only one email is sent.

I have had one instance where a user checked in multiple tests together (over 300 tests) from the "Pending Check In" dialog box - and all emails were sent. Subsequent tests by the same user only triggered a single email.

I have searched the forums and found a few (old) posts where people are trying to achieve something very similar to what I've described, however the only posts I have seen seem to indicate there is no way to trigger the script for multiple tests being checked in together.

 

Is anybody able to please answer the following two questions:

  1. Is there  another or better way to achieve what I am trying to do?
  2. What could cause a single instance of the script being triggered for all items checked in by one user, while every time I try and do the same thing the script is only triggered once and only one email is sent?

We are using ALM Version 15.5.1 (Build 82).

Below is a copy of my workflow script:

Sub TestPlan_ActionExecuted(ActionName)
   'Uncomment line below to get info on TestPlan_ActionExecuted
   'Msgbox "Test_Plan_ActionExecuted(ActionName): " & ActionName & " ActiveModule: " &  ActiveModule
   If ActionName = "act_vcs_checkin" OR _       'This is ActionName when a test is checked in directly from the toolbar
      ActionName = "PendingCommandList.Pending.CheckIn" then  'This is the ActionName when a test is checked in from "Pending Check In"
      Dim emailTo, emailCC, emailSubject, objectId
      Dim designApprovalStatus, designApprover, clientApprovalStatus, clientApprover
      Dim emailDocControl
      emailDocControl = "test@mydomain.com"

      'Set below to variables for ease of readability
      designApprovalStatus = Test_Fields("TS_USER_01").Value
      designApprover = Test_Fields("TS_USER_02").Value
      clientApprovalStatus = Test_Fields("TS_USER_03").Value
      clientApprover = Test_Fields("TS_USER_04").Value
      objectId = Test_Fields("TS_TEST_ID").Value


      if (designApprovalStatus = "Pending") then
          emailTo = designApprover
          emailCC = ""
          emailSubject = "ALM Designer Approval required - Test: " & Test_Fields("TS_NAME").Value
          Call SendTest(objectId, emailTo, emailCC, emailSubject, emailBody)
          MsgBox "Approval Request Email Sent to " & designApprover
      elseif (designApprovalStatus = "Rejected") then
          emailTo = Test_Fields("TS_RESPONSIBLE").Value 'User specified in Designer Field
          emailCC = ""
          emailSubject = "ALM Test Rejected by Design Approver: " & Test_Fields("TS_NAME").Value
          Call SendTest(objectId, emailTo, emailCC, emailSubject, emailBody)
          MsgBox "Rejected Email Sent to " & Test_Fields("TS_RESPONSIBLE").Value
      elseif (clientApprovalStatus = "Pending") then
          emailTo = clientApprover    'User specified in field
          emailCC = emailDocControl
          emailSubject = "ALM Client Approval required - Test: " & Test_Fields("TS_NAME").Value
          Call SendTest(objectId, emailTo, emailCC, emailSubject, emailBody)
          MsgBox "Approval Request Email Sent to " & clientApprover
      elseif (clientApprovalStatus = "Rejected") then
          emailTo = designApprover  'User specified in Field
          emailCC = "[TestTeam], " & Test_Fields("TS_RESPONSIBLE").Value 'Users in group and Designer Field
          emailCC = emailCC & ", " & emailDocControl
          emailSubject = "ALM Test Rejected by Client : " & Test_Fields("TS_NAME").Value
          Call SendTest(objectId, emailTo, emailCC, emailSubject, emailBody)
          MsgBox "Rejected Email Sent to " & designApprover
      elseif InStr(clientApprovalStatus, "Approved") then
          emailTo = designApprover  'User specified in Field
          emailCC = "[TestTeam], " & Test_Fields("TS_RESPONSIBLE").Value 'Users in group and Designer Field
          emailCC = emailCC & ", " & emailDocControl
          emailSubject = "ALM Test Approved by Client : " & Test_Fields("TS_NAME").Value
          Call SendTest(objectId, emailTo, emailCC, emailSubject, emailBody)
          MsgBox "Approved Email Sent to " & designApprover
      end if

   end if

End Sub 'TestPlan_ActionExecuted

Sub SendTest(iObjectId, strTo, strCc, strSubject, strComment)
   On Error Resume Next
   Dim objTestFactory, objTest
   Set objTestFactory = TDConnection.TestFactory
   Set objTest = objTestFactory.Item(iObjectId)
   objTest.Mail strTo, strCc, 1+2+8+32768, strSubject, strComment
   'For email content flags see https://admhelp.microfocus.com/alm/api_refs/ota/Content/ota/topic9931.html
   Set objTest = Nothing
   Set objTestFactory = Nothing
   PrintError "SendTest"
   On Error GoTo 0
End Sub

  • Hi,

    Did you get any solution for this? I am also stuck at the same point.

  • It seems a limitation of the workflow.

    Would you mind opening a support ticket to Micro Focus (OpenText) and our RnD team will try to help?

  • Suggested Answer

    if you check in  / check out multiple items by multi selection , you can get each of the selected item by ActiveTreeSelection,

    for example:

        if ActionName = "act_vcs_checkin" then
           set selectedItems = ActiveTreeSelection
           for each currentItem in selectedItems
               msgbox currentItem.Field("TS_NAME") & " is designed by " & CurrentItem.Field("TS_RESPONSIBLE")
           next
        end if

  • if you check in  / check out multiple items by multi selection , you can get each of the selected item by ActiveTreeSelection,

    for example:

        if ActionName = "act_vcs_checkin" then
           set selectedItems = ActiveTreeSelection
           for each currentItem in selectedItems
               msgbox currentItem.Field("TS_NAME") & " is designed by " & CurrentItem.Field("TS_RESPONSIBLE")
           next
        end if

  • Hi  ,

    Thanks for your suggestion.

    I have tried the same code for checking in multiple test cases at once. When i am selecting more than one test cases the msgbox is getting triggered twice the number of selected test cases.

    For example -
    If i select 3 test cases and checkin using checkin button from the tool bar, then the 6 msgboxes are popping up one after the other.
    If we are selecting test cases in order 'A','B','C' then the msgbox is appearing in order 'A','B','C','A','B','C'.

    When i tried sending email instead of displaying the msgbox, then the email is getting triggered twice the number of selected test cases for check in however all the emails are pointing to the first selected test case.
    If we are selecting test cases in order 'A','B','C' then the email is triggering in order 'A','A','A','A','A','A'.

    Can you please check and help us with this.

  • works fine on my machine.

    1. please check if the event is triggered twice in your environment, you can put a msgbox ActionName at the beginning to verify.

    2. even if there are duplications, since you can get 'A', 'B', 'C' how come all mail are on 'A' 'A' 'A'?

    can you post your code ?

  • We tried again, it worked this time. However we are still stuck on using the 'Checkin' button present on right top side. We have not been able to find a way to reference the selected items in our code.
    As suggested by David Fu, could you please confirm if this could be a limitation of ALM Workflow? If yes, is there any alternative to get the reference of the selected items in that box?