- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020 11:15 PM
Hi All,
Working on test case for creation of problem from incident. After submitting the incident form a problem record is created.
I want to access that record via the problem reference field from the incident. How to do that via server side script in atf?
Please let me know if we have any other alternative to achieve this as I need to open the problem record and then validate some field values.
Ps: Already tried via open problem record in the list view, but it doesn't seem to do anything after opening the list view.
Thanks
Solved! Go to Solution.
- Labels:
-
Automated Test Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 08:51 AM
Hi Archana,
Here is the approach I used to test the problem created from Incident.
I was able to open successfully the problem record which got created after clicking the UI Action "Create Problem"
Script Used in Run Server Side Script: I have given Step 3 sys_id since UI Action would be clicked from that incident
You give yours
(function(outputs, steps, stepResult, assertEqual) {
// add test script here
var incRec = new GlideRecord('incident');
incRec.get(steps('21af3568db1d141059badd384b961901').record_id); // sys_id of step 3
outputs.table = 'problem';
outputs.record_id = incRec.problem_id;
stepResult.setOutputMessage("Successfully Found Problem record");
return true;
})(outputs, steps, stepResult, assertEqual);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2020 01:18 AM
Hi Archana,
please update it as below
ensure you use the record_id value while opening the problem in next step
Step 12 sys_id you need to use in query since that is the 3rd incident
(function(outputs, steps, stepResult, assertEqual) {
// add test script here
var step12SysId = '';
var gr = new GlideRecord("problem");
gr.addQuery('first_reported_by_task, steps(step12SysId).record_id);
gr.query();
if(gr.next()) {
outputs.table = 'problem';
outputs.record_id = gr.sys_id;
stepResult.setOutputMessage("This is the Problem sys_id: " + gr.sys_id);
stepResult.setSuccess();
return true;
}
})(outputs, steps, stepResult, assertEqual);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2020 04:14 AM
Is this answered?
if my answer helped you, kindly mark it as ✅ Correct & 👍Helpful so that it does not appear in unanswered list & close the thread.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 08:51 AM
Hi Archana,
Here is the approach I used to test the problem created from Incident.
I was able to open successfully the problem record which got created after clicking the UI Action "Create Problem"
Script Used in Run Server Side Script: I have given Step 3 sys_id since UI Action would be clicked from that incident
You give yours
(function(outputs, steps, stepResult, assertEqual) {
// add test script here
var incRec = new GlideRecord('incident');
incRec.get(steps('21af3568db1d141059badd384b961901').record_id); // sys_id of step 3
outputs.table = 'problem';
outputs.record_id = incRec.problem_id;
stepResult.setOutputMessage("Successfully Found Problem record");
return true;
})(outputs, steps, stepResult, assertEqual);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2020 11:20 PM
Hi Ankur,
This is working fine now.
Thanks for your help!
Archana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2021 05:32 PM
Hi Ankur,
I am using the above server side script for one of my similar requirement. But getting error. Please find the screenshots below.
Please correct me if I m doing wrong.
Reference field on alert form