How to create RITM backend using ATF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
how to create a manual RITM from the backend using ATF?
I need to follow this approach since the portal submission is blocked due to the Custom-type variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
You can do this in ATF without touching the portal UI by creating the REQ/RITM server-side (Cart API / sn_sc.CartJS) and then querying the created RITM in later ATF steps.
This is the most reliable approach when a custom variable type blocks portal submission.
Approach A (recommended): ATF + “Run Server Side Script” to create the RITM
Step 1 — Create an ATF Test
Go to Automated Test Framework > Tests
Create a new test (e.g., Create RITM backend – <catalog item>)
Step 2 — Impersonate the requester (important)
Add ATF step:
Impersonate user
Choose the user who should submit the request (requested_for / opened_by context)
Step 3 — Run Server Side Script (creates REQ + RITM)
Add ATF step:
Run Server Side Script
Use a script like below (replace CAT_ITEM_SYS_ID and variable names/values).
This uses sn_sc.CartJS().orderNow() which is a common server-side pattern to submit a catalog item.
If you have MRVS (Multi-Row Variable Set): you usually set it as a JSON string via cart.setVariable(...) pattern (instead of plain variables:{}), like this community example.
Step 4 — Find the created RITM (Record Query)
Because ATF doesn’t always pass server-script outputs cleanly between steps, the usual trick is: stamp a unique marker (as above) and then query it.
Add ATF step:
Record Query
Table: sc_req_item
Condition: short_description contains ATF_RITM_ and sys_created_by is (your test user) and sys_created_on >= last X minutes
Order by sys_created_on desc, limit 1
(Community guidance commonly suggests querying by “created today / created by / known field value”. )
Step 5 — Open the RITM and assert downstream behavior
Add ATF steps like:
Open Existing Record (use output of Record Query)
Assert Field Values
If your flow creates tasks/approvals:
Record Query on sc_task where request_item = <RITM>
Assert count/state/assignment group, etc.
Approach B (if you only need to test fulfillment, not ordering): “Replay Request Item”
If your real goal is to test the post-ordering process (approvals/tasks/flow), ATF has a Replay Request Item concept where you replay an existing RITM to test the ordering process once a request exists.
This avoids portal ordering entirely—but you’ll need a seed RITM in the system.
Why this works for your situation
Your portal submission is blocked due to the custom variable type (UI / portal behavior).
Creating the request via server-side Cart API bypasses the portal UI layer and is a standard automation technique for catalog ordering.
Quick checklist / common pitfalls
Run as a user who has permission to order that catalog item.
Ensure required variables are set (otherwise the item might submit but fail downstream).
If your custom variable type drives mandatory logic, replicate that logic by setting the equivalent backend values.
If orderResult doesn’t return the request sys_id in your instance, use the fallback query method (created_by + cat_item + last 10 minutes).
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks
Nayan Patel
IT ServiceNow Consult, ServiceNow ArchX
If my response has resolved your query, please mark it Helpful by giving it a thumbs up and Accept the Solution
