- 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
07-21-2020 04:16 AM
Hi Ankur,
Test step:In the left side navigation panel, search for any business Service and open it whose environment is “QA. 'On the form, navigate to “Related Items” section.
Click on “+” icon which is available on the right side of “Related items” section to open the relationship editor”.On the relationship editor form, Select ‘Instantiated by’ relationship under ‘Use suggested relationships’ section, Go to “Filter” section and provide the filter conditions as below. Class - is – Business Service (select from drop down list) and click on ‘Run filter’.
I wrote script it runs 100% but in client script runner not navigate relation item section and set filter and run the filter.
(function(outputs, steps, stepResult, assertEqual) {
// add test script here
var gr=new GlideRecord('cmdb_ci_service');
gr.get(steps('6d4d4076db465054c9497ba5329619e8').record_id); //previous step sys id
outputs.table = "OQ_ITSM_ACM_00002_TC004_Environment should not inherit from Service to Service";
outputs.record_id =gr.f9677af6db7d9cdc62357ba53296196b; //table sys id
stepResult.setOutputMessage("Successfully found record");
return true;
//add data and validate
var testAssertion;
{
testAssertion.name="Related Item";
testAssertion.shouldb="+";
testAssertion.value= "suggest relationship type";
testAssertion.name="suggest relationship type";
testAssertion.shouldbe="Instantiated by";
testAssertion.value="Instantiated by child";
testAssertion.name="filter";
testAssertion.shouldbe="class";
testAssertion.value="Business Service";
stepResult.setOutputMessage("Successfully run filter ");
};
assertEqual(testAssertion);
})(outputs, steps, stepResult, assertEqual);
Please let me know if we have any other alternative to achieve this as I need .