Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

Server category

Perform server-side operations. For example, query and update a record, impersonate a user, or run a server-side script.

Create a User

Create a user with specified roles and groups for the test. The user record gets rolled back after the test completes.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them. You can change this default order by editing the Execution order values.
ApplicationApplication scope in which the system runs this step.
ActiveOption to activate this test step for use.
TestName of the test that you're adding the step to.
Step configName of the step.
NotesNotes about the test step.
First nameFirst name of the user.
Last nameLast name of the user.
RolesAssigned roles of the user.
GroupsAssigned groups of the user.
Impersonate this userOption to impersonate the new user.
FieldDescription
userThe user ID of the user impersonated.

Impersonate

Impersonate the specified user for the test.

Impersonate specifies a user for executing subsequent steps in this test. It works for both server-side and browser-side steps and stays in effect until changed with another Impersonate step or until the test ends. The impersonation automatically ends when the test is over.

Note:

  • Do not impersonate a user with the test author role. Doing so can lead to conflicts that interfere with executing the test.
  • Tests which involve impersonated users which no longer exist fail.

    Tip: It is recommended to create a new user to avoid data dependencies. See Create a User, for more information.

  • Do not rely on user IDs being consistent across different instances. The system dynamically assigns users IDs, so the ID for a particular user often differs from one instance to the next.

  • When exporting and importing automated tests, keep in mind that update sets do not update the user field.
  • Tests can impersonate users with the snc_external role, which allows testing users who do not have login access. See Explicit Roles for requirements of the snc_external role.
FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
UserThe user ID for the test to impersonate.
FieldDescription
userThe user ID of the user impersonated.

Search for a Catalog Item

Searches for a catalog item or record producer in the specified catalog and category. You can perform this step both in Platform and Service Portal.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.
Search in Portal onlySelected if the search is restricted to the Service Portal only. Otherwise, not selected.
Search termTerm used to search for a catalog item.
CatalogCatalog in which to search for the catalog item.
CategoryCategory in which to search for the catalog item.
Assert itemCatalog items that should be available in the search results.
Assert TypeSpecifies how searching the catalog item affects the test:- Assert Item present in search result: Test passes only if the assert item is present in the search result. - Assert Item not present in search result: Test passes only if the assert item is not present in the search result.
FieldDescription
catalog_item_idThe sys_id of the first catalog item found that the user can view.

Record Query

Query the database to verify that a record exists matching the conditions set in this step.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
TimeoutNumber of seconds allowed before the step fails. If the validation fails, the system repeats the step until it reaches the duration of the timeout. If the validation fails after the timeout duration has passed, the step fails.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
Enforce securitySelected to enforce ACLs. Otherwise, not selected.
NotesNotes about the test step.Note: Use the condition builder to set the field value. The condition builder displays an appropriate control for the field data type. For example, a reference field displays a Lookup record control.
Assert typeSpecifies how querying the record affects the test:- There is at least one record matching the query: The test fails if there are no records matching the query. - No records match the query: The test fails if any records match the query.
TableThe table to be queried.
ConditionsConditions used to run the query.
FieldDescription
tableThe table queried.
first_recordThe first record resulting from the query.

Note: If you don’t update your record query test step, the original record query test step still functions the same way as before, irrespective of it being termed as (Deprecated).

Record Insert

Inserts a record into a table with the field values you specify.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.Note: Use the condition builder to set the field value. The condition builder displays an appropriate control for the field data type. For example, a reference field displays a Lookup record control.
Assert typeSpecifies how inserting the record affects the test:- Record successfully inserted: Test fails if the record was not successfully inserted. - Record was not inserted: Test fails if the record was successfully inserted.
Enforce securitySelected to enforce ACLs and the read-only role. Otherwise, not selected.
TableThe table into which the record should be inserted.
ConditionsSpecific field values to be set when the test runs this step.
FieldDescription
tableThe table to which the new record belongs.
record_idThe sys_id of the new record.

Record Update

Changes field values on a record on the server.

Note: To ensure that the changes were applied, follow this step with a Record Validation step.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.Note: Use the condition builder to set the field value. The condition builder displays an appropriate control for the field data type. For example, a reference field displays a Lookup record control.
Assert typeSpecifies how updating the record affects the test:- Record successfully updated: Test fails if the record was not successfully updated. - Record was not updated: Test fails if the record was successfully updated.
Enforce securitySelected to enforce ACLs and the read-only role. Otherwise, not selected.
TableThe table containing the record to be updated.
RecordID of the record to be updated.
Field valuesFields for which you want to set values and the values you want to set for those fields.Note: Use the condition builder to set the field value. The condition builder displays an appropriate control for the field data type. For example, a reference field displays a Lookup record control.

Note: Record Update step succeeds even if a field on the record is blocked by ACL. Use the Record Validation step after Record Update to check whether a particular field was modified, or use the Form steps to evaluate ACL conditions for individual fields on a record.

Record Delete

Deletes a specified record in a table.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.
Assert typeSpecifies how updating the record affects the test:- Record successfully deleted: Test fails if the record was not successfully deleted. - Record was not deleted: Test fails if the record was successfully deleted.
Enforce securitySelected to enforce ACLs and the read-only role. Otherwise, not selected.
TableThe table containing the record to be deleted.
RecordID of the record to be deleted.

Record Validation

Validates that a record meets the specified conditions on the server side.

For the Record Validation step, specify the values you want to test using the standard conditions builder. You can apply several conditions to the same field.

This step passes if the overall condition is satisfied and fails if it is not. If you need to test the values of individual fields independently of each other, include a separate Record Validation step for each value to be tested.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
TimeoutNumber of seconds allowed before the step fails. If the validation fails, the system repeats the step until it reaches the duration of the timeout. If the validation fails after the timeout duration has passed, the step fails.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.Note: Use the condition builder to set the field value. The condition builder displays an appropriate control for the field data type. For example, a reference field displays a Lookup record control.
Assert typeSpecifies how validating the record affects the test:- Record successfully validated: The test fails if the record does not match the conditions. - Record not found: Test fails if the record is found.
TableThe table that contains the field to be validated.
RecordThe record that contains the field to be validated.
Field valuesSpecific fields to be validated when the test runs this step.

Run Server Side Script

Executes a script on the server.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.
Jasmine versionThe version of the Jasmine testing framework to use for running the server-side script. Any new scripts you create use Jasmine version 3.1. Your existing scripts can continue to use Jasmine version 1.3, or you can upgrade them to Jasmine version 3.1.
Test script

The javascript for the server to execute. Supports the Jasmine testing framework.Note: steps(SYS_ID) can be defined as a function to retrieve Output variable data from a step that executed earlier in the test.

The Run Server Side Script test step now supports parameters as step inputs.

FieldDescription
record_idThe sys_id output by the server-side script.
tableThe table output by the server-side script.

Note: If the script creates data, the system rolls back that data after all steps in the test finish. The output for the Run Server Side Script test step now indicates the line and the line number for the cause of failure.

  • Test script

    //  Test step 1 - add data
    var now_GR = new GlideRecord('sc_task');
    //  this sample step's Step config has Output variables named table and record_id
    outputs.table = 'sc_task';
    outputs.record_id = gr.insert();
    //  Test step 2 - access added data and validate
    //  check that the record exists (or that business logic changed it)
    var now_GR = new GlideRecord("sc_task");
    gr.get(steps(PREVIOUS_STEP_SYS_ID).record_id);
    assertEqual({name: "task gr exists", shouldbe: true, value: gr.isValidRecord()});
    stepResult.setOutputMessage: Log a message to step results after step executes.
                                 Can only be called once or will overwrite previous message
    
  • Create a suite of test scripts

    var now_GR = new GlideRecord('sc_task');
    gr.setValue('short_description', 'verify task can be inserted');
    var grSysId = gr.insert();
    var justCreatedGR = new GlideRecord('sc_task');
    if (justCreatedGR.get(grSysId)) {
    stepResult.setOutputMessage("Successfully inserted task record");
    return true; // pass the step
    } else { 
    stepResult.setOutputMessage("Failed to insert task record");
    return false; // fail the step
    }
    
  • Jasmine test

    describe('my suite of script tests', function() {
    it('should meet expectations', function() {
    expect(true).not.toBe(false);
    });
    });
    //  make sure to uncomment jasmine.getEnv().execute(); outside the function body
    assertEqual: A function used to compare that assertion.shouldbe == assertion.value;
    in case of failure it throws an Error and logs that the assertion by name has failed
    

    Note: describe is only supported in Global scope. Use describe to create a suite of test scripts and it to define test expectations.

  • Logs message to test step output

    var testAssertion = {
    name: "my test assertion",
    shouldbe: "expected value"
    value: "actual value",
    };
    assertEqual(testAssertion); // throws Error, logs message to test step output
    
  • See Step Execution Scripts for Run Server Side script example.

Replay Request Item

Get the item and requester from an existing request item, add the item to a new cart for that user, and place an order.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.
Original Request ItemThe request item to be replayed.
FieldDescription
tableThe table to which the replayed request item belongs.
requestThe replayed request item.

Related topics

Automated Test Framework use case: test a Service Catalog request

Log

Logs a message and stores it as a step result.

The log message can contain variables and other information pertaining to the test. The message is stored as a step result.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.
LogThe message to be logged. To include the value of an output variable from a previous step, click the input value icon \(
Image omitted: rem-value-icon.png
Input value icon\) and follow the procedure to <a href="../atf-retrieve-value/">Pass values from one automated test step to another</a>.

Add Attachments to Existing Record

Add one or more mandatory attachments to the specified record. Use Upload Attachments to select from the attachments the test step adds to the record.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them. You can change this default order by editing the Execution order values.
ApplicationApplication scope in which the system runs this step.
ActiveOption to activate this test step for use.
TestName of the test that you're adding the step to.
Step configName of the step.
NotesNotes about the test step.
TableValid table selection from the list.
RecordPre-existing record either from before the test or inserted as a part of the test.
Upload AttachmentsButton to add one or more mandatory attachments to the record.

Checkout Shopping Cart

Submits the cart and generates a request. You can perform this step both in the ServiceNow AI Platform and Service Portal.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
TimeoutNumber of seconds allowed before the step fails. If the validation fails, the system repeats the step until it reaches the duration of the timeout. If the validation fails after the timeout duration has passed, the step fails.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.
Assert Type

Criteria for the test to pass.- Empty cart

Test fails if the cart is not empty.

  • Successfully Checkout cart

Test fails if the cart is not successfully checked out.

Requested ForUser for whom the request is generated.
Delivery AddressDelivery address for the request.
Special InstructionsSpecial instructions for the request.
FieldDescription
request_idThe sys_id of the submitted request.

Custom Scripted StepConfig

Provides an example of scripts for a custom step configuration.

This example checks if the user name provided starts with the letter A. This step is useful primarily to users with the [atf_test_admin] role. Users with the [atf_test_admin] role can view the example scripts by opening the record for this step in Step configurations.

FieldDescription
Execution orderInteger specifying the order in which the test executes this step.As you create steps, the system automatically assigns each step an incremental value. This value causes the test to execute steps in the order that you created them in. You can change this default order by editing the Execution order values.
ActiveOption to activate this test step for use.
ApplicationApplication scope in which the system runs this step.
TestRead-only name of the test that you're adding the step to.
Step configRead-only name of the step.
DescriptionDescription of the test step. This field value is automatically set based on the field values of the test step. This field appears after the test step is submitted.
NotesNotes about the test step.
UserThe user whose name the system checks to see if it starts with the letter A. To include the value of an output variable from a previous step, click the input value icon (
Image omitted: rem-value-icon.png
Input value icon) and follow the procedure to <a href="../atf-retrieve-value/">Pass values from one automated test step to another</a>.</td></tr></tbody>
FieldDescription
valueThe name of the user.

Related topics

Create custom step configuration

Step execution scripts

Step description generation script

sndocs is an independent community mirror and is not affiliated with or endorsed by ServiceNow.

ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are associated.

© 2026 ServiceNow, Inc. All rights reserved.

Documentation content is redistributed under the Apache License 2.0 from the ServiceNowDocs repository.