- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 06:23 AM
Hello,
I have an ATF that I created. It involves ordering an item from the Service Portal. When I get to the approval process and marking tickets as Closed Complete, I jump to the server section and use the Replay Request Item. This allows me to grab the ticket number.
Where my test is failing:
It fails at Step 15. I am trying to do a Record Query to get back the sc_task and close the task, but the error I keep getting is "No records matching query" as shown below:
This is what my query step looks like:
Once this step is figured out, I want to add a Record Update to close the sc_task.
**Note**
When an item is ordered on our portal, closing the task does not close the RITM and closing the RITM does not close the REQ. This is a manual process. The RITM and SCTASK display as a related list under the REQ at same time and I think that is whats making this so difficult.
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2020 06:09 AM
Okay thanks for your reply 🙂
I would suggest below steps:
1)- Record Query : sysapproval_approver [Step 13 already in place]
- Approval For: Pass the request item
- Retrieved atleast one record
2) Open an existing record (pass the id return in above step)
3) click a ui action (here please select ui action:approve)
[Note: Please don't use record update to change it to approved] instead use step 2 & 3
If you have some queries please feel to ask:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2020 02:29 AM
Hi,
you want to approve the RITM right or the Request?
As you are running the script the field being disabled should not be an issue.
I assume you want to approve RITM so try this
gr.addQuery('sysapproval', chg);
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
‎07-29-2020 03:43 AM
You can add some log in while loop to check whether it is fetching any record for approver or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2020 04:38 AM
I know the REQ needs to be approved to kick start the process. If I Approve the REQ, then the RITM will also be accepted. My main issue is Approval on the request not being approved and the SCTASK not being created after the approval.
Also, I added the query your provided and still did not work: gr.addQuery('sysapproval', chg);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2020 05:04 AM
in that case please try this
1) Get the RITM from step 8
2) Query RITM to get the Request sys_id
3) Use that in your query to approval table
Updated Script below
(function(outputs, steps, stepResult, assertEqual) {
var ritm = steps('SYS ID STEP 8').first_record; // give sys_id of step number 8
var reqSysId = '';
var ritmRecord = new GlideRecord('sc_req_item');
ritmRecord.addQuery('sys_id', ritm);
ritmRecord.query();
if(ritmRecord.next()){
reqSysId = ritmRecord.request.toString();
}
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', reqSysId);
gr.addQuery('state', '!=', 'approved');
gr.query();
while(gr.next()) {
gr.state = 'approved';
gr.update();
}
// these lines are required to know the outcome
stepResult.setOutputMessage("Successfully Approved RITMs");
return true;
})(outputs, steps, stepResult, assertEqual);
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
‎07-29-2020 05:20 AM
I tested out the script and the same thing. It shows up as approved, but it is not approving. I have another follow up step that searches for the sctask and it fails there. I also verified it is not approving by opening the request being created. The state does not update to approved on the request
As you can see the sctask is empty