How to trigger email notifications by using ATF

chanikya
Tera Guru

Hi,

How to trigger email notifications by using ATF. can you please help me how to do it 

if you share the solution with Screenshots that will helpful for me

1 ACCEPTED SOLUTION

georgimavrodiev
Mega Guru

Hello Chanikya,


As you know, the ATF functionality is configured in such way that all records created during the execution of an ATF tests gets automatically deleted after its completion or fail. This means that an ATF cannot send a real Email Notification to a user or at least not OOB. Under 'real' I mean you will not receive it in your email.

However, it is absolutely possible to use an ATF test to confirm if Email Notifications are being sent by the targeted ServiceNow instance.
For example - if you did any modifications on existing Email Notifications or you created custom ones -> then, you may use an ATF test to check if in reality these Notifications will be triggered if their triggering conditions are match.

I will give you a use case example:

- OOB there is an Email Notification, called "Problem assigned to me". It runs against Problem (problem) table and will be sent when a Problem record is inserted or updated + its 'Assigned to' field changes & is not 'empty'. The Notification will be sent to the assignee ('Assigned to') of the respective problem record;
- you may use an ATF test to check if this notification is actually being triggered by creating a really simple and short ATF test. Here are the steps you may use:

find_real_file.pngfind_real_file.png1. 'Impersonate' to a user with ITIL role;
2. 'Open a New Form' against Problem (problem) table;
3. 'Set Field Values' and populate the assignee of the opened problem for (Assigned to = a user with real email ID);
4. 'Submit a Form' -> this step will submit the problem form;
5. 'Record Query' -> you need to run this step against Email (sys_email) table + Conditions: Subject contains Problem & Created on is Today & Recipients contains the email of the user from step 3 (the Assignee of the Problem record);
6. 'Open an Existing Record' -> here, you need to open the record of step 5;

NOTE: Detailed description: basically, you will configure the ATF test of yours to impersonate to a user who has ITIL role. Then, this user will open a new problem record and will populate its assignee by adding a user with real email ID. Then, the test will submit the problem for in order for the new problem record to be created (inserted). After that the test will go to the Email (sys_email) table where all sent, read for sending and received Email Notification records are being stored. There, it will check for the existing of a record which was created today & which recipient was the assignee of the Problem & which has in its Subject field 'Problem'. Once such record gets found -> it will be opened and you will be able to review it. If such record is not found -> then the ATF test will fail with an error, meaning that the Notification has not been triggered due to an issue (with it or its conditions).

- during the ATF test execution (once you Run it) -> you will have to watch the steps execution via the Test Runner window in order to see the behavior is as expected;

Now, after knowing the above information, you may go ahead and configure an ATF test against a custom Email Notification of yours. 
This will give you the opportunity to perform tests of any further notification customization - s on your DEV and confirm the behavior after the customization - s were done, before going forward and implementing the same on your PROD.


Hope this information will be of use to you, Chanikya!


Best Regards,
Georgi Mavrodiev

IT Consultant
Do IT Wise Bulgaria

You may visit us in our Web Site: www.doitwise.com

View solution in original post

6 REPLIES 6

mishu1
Tera Guru

Hi Chanikya,

 

As an out-of-box capability, its not possible to trigger notifications for a test suite, however you can configure an event/registry and then fire this event from a business rule on the Test suite table available within the Automated test framework application. 

 

Regards,

Mishu

 

Note: Please mark this response as "Helpful", if in case it has resolved your query. 

georgimavrodiev
Mega Guru

Hello Chanikya,


As you know, the ATF functionality is configured in such way that all records created during the execution of an ATF tests gets automatically deleted after its completion or fail. This means that an ATF cannot send a real Email Notification to a user or at least not OOB. Under 'real' I mean you will not receive it in your email.

However, it is absolutely possible to use an ATF test to confirm if Email Notifications are being sent by the targeted ServiceNow instance.
For example - if you did any modifications on existing Email Notifications or you created custom ones -> then, you may use an ATF test to check if in reality these Notifications will be triggered if their triggering conditions are match.

I will give you a use case example:

- OOB there is an Email Notification, called "Problem assigned to me". It runs against Problem (problem) table and will be sent when a Problem record is inserted or updated + its 'Assigned to' field changes & is not 'empty'. The Notification will be sent to the assignee ('Assigned to') of the respective problem record;
- you may use an ATF test to check if this notification is actually being triggered by creating a really simple and short ATF test. Here are the steps you may use:

find_real_file.pngfind_real_file.png1. 'Impersonate' to a user with ITIL role;
2. 'Open a New Form' against Problem (problem) table;
3. 'Set Field Values' and populate the assignee of the opened problem for (Assigned to = a user with real email ID);
4. 'Submit a Form' -> this step will submit the problem form;
5. 'Record Query' -> you need to run this step against Email (sys_email) table + Conditions: Subject contains Problem & Created on is Today & Recipients contains the email of the user from step 3 (the Assignee of the Problem record);
6. 'Open an Existing Record' -> here, you need to open the record of step 5;

NOTE: Detailed description: basically, you will configure the ATF test of yours to impersonate to a user who has ITIL role. Then, this user will open a new problem record and will populate its assignee by adding a user with real email ID. Then, the test will submit the problem for in order for the new problem record to be created (inserted). After that the test will go to the Email (sys_email) table where all sent, read for sending and received Email Notification records are being stored. There, it will check for the existing of a record which was created today & which recipient was the assignee of the Problem & which has in its Subject field 'Problem'. Once such record gets found -> it will be opened and you will be able to review it. If such record is not found -> then the ATF test will fail with an error, meaning that the Notification has not been triggered due to an issue (with it or its conditions).

- during the ATF test execution (once you Run it) -> you will have to watch the steps execution via the Test Runner window in order to see the behavior is as expected;

Now, after knowing the above information, you may go ahead and configure an ATF test against a custom Email Notification of yours. 
This will give you the opportunity to perform tests of any further notification customization - s on your DEV and confirm the behavior after the customization - s were done, before going forward and implementing the same on your PROD.


Hope this information will be of use to you, Chanikya!


Best Regards,
Georgi Mavrodiev

IT Consultant
Do IT Wise Bulgaria

You may visit us in our Web Site: www.doitwise.com

Hello Chanikya,



Hope you are doing great!


I would like to correct my self in regards to one statement of mine, mentioned earlier during the investigation of your query.
The approach to cover your requirement, which I provided to you is correct. Yet, I have to say that ATF tests can send real Email Notifications to users, no matter the fact that the records created during their execution will be automatically deleted at the end of the tests.

If you have any Email Notifications configured on the target instance (for example: Notifications for each state of an Incident) -> then, if the ATF test you are executing triggers the sending conditions -> the Notifications will be sent over to the respective recipients. 
The characteristic here comes from the fact that after the test ends -> the records created by it will be deleted and if a recipient who received a Notification tries to reach the respective record through it (the Notification) -> he will be informed that such record does not exist.

Please note that.


All the best, Chanikya,!


Cheers,
Georgi Mavrodiev

IT Consultant,
Do IT Wise Bulgaria

You may visit us in our Web Site: www.doitwise.com

Can you Suggets me how to Open Problem record of incidents.

 

 

From Problem record i have to open Incident record, so how can i do it please help me here

here i have One record, in future if i have 7 incidents under problem then how can i open that 7-incident from Problem

find_real_file.png