Automation Testing, Manual Testing, QTP/UFT 11 , QC/ALM 11 ,SAP TAO, Unix, Selenium, Oracle SQL, Shell Scripting and For Online Trinings to contact me : Cell:+91-8897972059 , Email Id : quicktestprotech@gmail.com

Wednesday, August 13, 2014

Sending Email from the Quality Center/ALM Workflow


Sending Email from the Quality Center Workflow




 Sending an E-Mail from the Workflow


Purpose: The following code template allows sending any object in TestDirector (Defect, Test, etc.) by e-mail. The code can be used to extend the automatic mail notifications with custom conditions, not available for Send All Qualified. The template uses TestDirector mailing functions.
Code Location:  The code for the each object should be placed in the script of the corresponding module. For example: SendDefect function should be placed in Defects module.

Arguments:
iObjectId – The ID of the object that should be sent (see the note below on how to obtain the object ID).
strTo – The TestDirector names or e-mails of the people that will appear in To field of the e-mail (the names and e-mails should be separated by semicolon. For example: “user@domain.com;admin;alice_td”).
strCc – The TestDirector names or e-mails of the people that will appear in Cc field of the e-mail (the names and e-mails should be separated by semicolon. For example: “user@domain.com;admin;alice_td”). Specify an empty string (“”) to omit this parameter.
strSubject – The e-mail Subject. Specify an empty string (“”) to omit this parameter.
strComment – The e-mail comment (will appear at the top of the e-mail). Specify an empty string (“”) to omit this parameter.
Notes:
1. The object ID value can always be retrieved using the {Object}_Fields collection, by retrieving the Value property of the ID field. The example below shows how to retrieve the Ids of Defect, Test and Requirement:

          ’ Defect ID – for SendDefect
          Bug_Fields(“BG_BUG_ID”).Value
          ’ Test ID – for SendTest
          Test_Fields(“TS_TEST_ID”).Value
          ’ Requirement ID – for SendReq
          Req_Fields(“RQ_REQ_ID”).Value
2. The templates for Defect, Test and Requirement are provided. However the function may be used to work with any object that has Mail function.
3. The third parameter in Mail function allows specifying e-mail options. In the templates below this parameter is hard-coded (its value 2 means that the object History will be sent). However you can change this value to any of the values of TDMAIL_FLAGS. You can use sum to combine the mail properties. For example: 1 – means “send attachments”; 2 – means “send history”. In order to send the mail with attachments and history, specify 3 for this argument.

Return Value:  None

Code Template:

Sub SendDefect (iObjectId, strTo, strCc,
     strSubject, strComment)
On Error Resume Next
Dim objBugFactory, objBug
Set objBugFactory = TDConnection.BugFactory
Set objBug = objBugFactory.Item(iObjectId)
objBug.Mail strTo, strCc, 2, strSubject, strComment
Set objBug = Nothing
Set objBugFactory = Nothing
PrintError “SendDefect
On Error GoTo 0
End Sub
''''''''''''''''''''''''''''''''''''''''''
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, 2, strSubject, strComment
Set objTest = Nothing
Set objTestFactory = Nothing
PrintError “SendTest
On Error GoTo 0
End Sub
'''''''''''''''''''''''''''''''''''''''''''''
Sub SendRequirement (iObjectId, strTo, strCc,
     strSubject, strComment)
On Error Resume Next
Dim objReqFactory, objReq
Set objReqFactory = TDConnection.ReqFactory
Set objReq = objReqFactory.Item(iObjectId)
objReq.Mail strTo, strCc, 2, strSubject, strComment
Set objReq = Nothing
Set objReqFactory = Nothing
PrintError “SendRequirement
On Error GoTo 0
End Sub
''''''''''''''''''''''''''''''''''''''''
Usage Example: In the following example when the test status is changed, the e-mail notification is sent to the designer of the test, cc to all the members of the [QA Testers] group.

          Sub TestPlan_Test_FieldChange(FieldName)
On Error Resume Next
Dim strSubject, strComment
If FieldName = "TS_STATUS" Then 
          strSubject = “Test Change Notification” & _
                             “ for project “ & TDConnection.ProjectName & _
                             “ in domain “ & TDConnection.DomainName
          strComment = “The user “ & User.FullName & _
 “ changed the status of the test ” & _
 Test_Fields(“TS_NAME”).Value & _
 “ to “ & Test_Fields(“TS_ STATUS”).Value
                   SendTest Test_Fields("TS_TEST_ID").Value, _
                                 Test_Fields(“TS_RESPONSIBLE”).Value, “[QA Testers]”, _
                                 strSubject, StrComment
          End If
On Error GoTo 0
End Sub

1 comment:

Loading...