- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 12:36 AM
In Test Management 2.0, is it possible to copy a test so that you don't have to start from scratch when creating a similar test (in case only a few steps differ)? It was possible in Test Management 1.0 but that functionallity seems to be gone.
Thanks in advance
Solved! Go to Solution.
- Labels:
-
Test Management
- 3,143 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2022 08:18 PM - edited ‎10-04-2022 10:28 PM
*I'm posting this reply again as it appears when the new community UI was rolled out this past weekend they didn't take the updates I posted from last week.
I had the same business need. I've just had a play around and have a solution.
I'll preface it by saying I'm very new to coding, so there may be a more efficient way to go about this, or you may find my code a tad messy. I can say, however, that my tests thus far with this solution are working as expected.
In Test Management 2.0 when you create a new Test what you are doing is creating a new Version (check the table you are on when you hit 'New' from the Test UI Action). When a new Version is created, it also creates a Test record and associates it.
I have created a new UI Action 'Duplicate' on the 'sn_test_management_test_version' table with the following script:
// Create new test version and in turn a new Test
var duplicate = new GlideRecord('sn_test_management_test_version');
duplicate.initialize();
duplicate.setValue('short_description', current.short_description + " 'Duplicated Test'");
duplicate.update();
// Find any steps which were on the test version
var getSteps = new GlideRecord('sn_test_management_step');
getSteps.addQuery('test_version', current.sys_id);
getSteps.query();
while (getSteps.next())
// For each step found, copy it and set its Test Version to the new version created
{
var newStep = new GlideRecord('sn_test_management_step');
newStep.initialize();
newStep.setValue('test_version', duplicate.sys_id);
newStep.setValue('step', getSteps.step);
newStep.setValue('order', getSteps.order);
newStep.setValue('needs_verification', getSteps.needs_verification);
newStep.update();
}
action.openGlideRecord(duplicate); // Redirect to the new Test Version
This will copy all the steps of the version and put them into a new one. The state of the duplicated version will be set to Draft by default. The redirect takes you to the new Version where you can simply update it as desired, save it, and mark it as Ready.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 05:00 PM
Sorry, not possible OOTB. How to duplicate a test script? - IT Business Management - Question - ServiceNow Community

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2022 07:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 05:57 AM
Worked like a champ and super easy solution. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 09:29 PM
Keep in mind using 'Insert and Stay' on a Test does not copy the associated Test Version or its Test Steps. Similarly, if you 'Insert and Stay' on a Test Version, you lose all the Test Steps, and it orphans the Test Version.
Using Insert and Stay in Test Management 2.0 is not advised.