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:
- Is there another or better way to achieve what I am trying to do?
- 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