Send Auto Mail when Test status is changed in Test Plan (803 Views)
Reply
Occasional Visitor
Rangineni
Posts: 2
Registered: ‎03-20-2012
Message 1 of 10 (803 Views)
Accepted Solution

Send Auto Mail when Test status is changed in Test Plan

Hi,

 

I am trying to create script which sends automatic mail with description and subject when test status is changed in testplan.

 

Till now i tried with the following code and able to get emails but the description and subject are not showing the one i added in script.

 

Can some one please help,

 

In Workflow - Script editor, i added following code under Test_Field Change procedure

 

Sub Test_FieldChange(FieldName)
Dim strSubject, strDes
If Test_Fields("TS_STATUS").IsModified Then

strSubject = "Test Change Notification" & " for project " & TDConnection.ProjectName & " in domain " & TDConnection.DomainName
strDes = "The user " & User.FullName & " changed the status of the test " & Test_Fields("TS_NAME").Value & " to " & Test_Fields("TS_ STATUS").Value
TDConnection.SendMail "xyz@abcd.com", "", strSubject, strDes, NULL,"HTML"
Set TDConnection = nothing
End If
End Sub

Please use plain text.
Honored Contributor
Jan Czajkowski
Posts: 2,025
Registered: ‎12-12-2007
Message 2 of 10 (798 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

You should try moving your code to Test_CanPost. If you keep it in FieldChange it is still possible that the user will cancel the changes, and then the email would be misleading. Also, you shouldn't set TDConnection to Nothing there - it is a global reference in the workflow that is automatically initialized when you log in to QC.

 

Do you mean you are getting information from another test in the email?

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Please use plain text.
Occasional Visitor
Rangineni
Posts: 2
Registered: ‎03-20-2012
Message 3 of 10 (780 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

Thank you Jan.

I tried with the comments provided by you and it is working fine now. We are getting mails for status change in test plan.

Please use plain text.
Frequent Advisor
LilM
Posts: 58
Registered: ‎02-24-2010
Message 4 of 10 (756 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

Hi Jan/team

 

I have been working on a similar code for a short while.  However, I want the automail to trigger when a test case has been changed in a particular folder.  Are you able to advise me the code?  For example, I want an email generated when a test case  has been changes to "Subject\01 Project Halo" in the Test Plan Module.

 

Your help would be greatly appreciated.

 

Regards

Lil M

Please use plain text.
Frequent Advisor
LilM
Posts: 58
Registered: ‎02-24-2010
Message 5 of 10 (753 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

Sorry I forgot to add my code...I want the automail to trigger of any change to a test case in particular folder, including the sub folders.

 

 

Function Test_CanPost
  On Error Resume Next
If InStr("Subject\folder\01 ACURITY - Regression Library", Test_Fields.field("TS_SUBJECT").Value>0) THEN
       strSubject = "Project " & TDConnection.ProjectName & " Test script " & Test_Fields("TS_NAME").Value & " has been modified"
       strTO = "XXX"
       strComment = "Test ID" & Test_Fields("TS_Test_ID").value
       strComment = "The User " & User.FullName & _
       " has made a change" 
       Set objTestFactory = TDConnection. TestFactory
       Set objTest = objTestFactory.Item(Test_Fields("TS_Test_ID").value)
       objTest.Mail strTO, strCC, 2, strSubject, strComment
       Set objTest = Nothing
       Set objTestFactory = Nothing
  End If
End Function

Please use plain text.
Honored Contributor
Jan Czajkowski
Posts: 2,025
Registered: ‎12-12-2007
Message 6 of 10 (747 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

To get the path to a certain Test Plan test, use

 

 msgbox Test_Fields("TS_SUBJECT").Value.Path

 

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Please use plain text.
Frequent Advisor
LilM
Posts: 58
Registered: ‎02-24-2010
Message 7 of 10 (739 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

[ Edited ]

Hi Jan.

Thank you for the msge box reference.

I learned the long way that QC is case and character spacing sensitive.  I ended up copy and paste the subject test plan folder in the code and it worked.  As well the msge box provided me with the correct path location of the subject test plan folder. 

 

So THANK YOU!

 

Lil M

Please use plain text.
Frequent Advisor
Eddy-Vazquez
Posts: 47
Registered: ‎06-25-2009
Message 8 of 10 (193 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

Hi Jan
I have the same problem but in the Requeriminets module.
The script is the following:

Sub Req_FieldChange(FieldName)
Dim strSubject, strDes
If FieldName("RQ_REQ_PRIORITY").IsModified Then
strSubject = "Test Change Notification" & " for project " & TDConnection.ProjectName & " in domain " & TDConnection.DomainName
strDes = "The user " & User.FullName & " changed the status of the test " & FieldName("RQ_REQ_PRIORITY").Value & " to " & FieldName("RQ_REQ_PRIORITY").Value
TDConnection.SendMail "eddy.vazquez@globallynx.com", "", strSubject, strDes, NULL,"HTML"
Set TDConnection = Nothing
End If
End Sub.

Is there an error in the code?
My code stayed in ReqCanPost.

I hope help me.
Regards
Please use plain text.
Honored Contributor
Jan Czajkowski
Posts: 2,025
Registered: ‎12-12-2007
Message 9 of 10 (180 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

Not sure what you mean. The script you are showing is located in FieldChange, not in CanPost.

 

What error are you getting? A syntax error?

 

Don't set TDConnection to Nothing. TDConnection is your session object that is running when you log in to QC. If you have a variable pointing to it you can set that variable to Nothing, but not the object itself.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Please use plain text.
Frequent Advisor
Eddy-Vazquez
Posts: 47
Registered: ‎06-25-2009
Message 10 of 10 (170 Views)

Re: Send Auto Mail when Test status is changed in Test Plan

Thank You for your response.
I solved the problem with your comments.
I commented the line Set TDConnection = Nothing.

Regards
Please use plain text.
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