code not working, wanted to check if the ritm is approved or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 08:32 AM
hi All,
i have more then 3000 request records, where i have to checked if the RITM is approved or not.
but my below code is not giving me any output.
Can you please edit my code and help me
CODE:-
var n;
var v = new GlideRecord('sc_req_item');
v.addEncodedQuery('numberINRITM8513815,RITM8513711');
v.query();
while (v.next()) {
n = v.number;
}
var ap = new GlideRecord('sysapproval_approver');
ap.addQuery('sysapproval.name', n);
ap.addQuery();
while (ap.next()) {
gs.log(ap.state);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 07:20 PM
Hi @BrightJunin,
If you are checking if the RITMs are approved or not, there is no need to query the [sysapproval_approver] records.
You can simply check the 'approval' field of the RITM.
e.g. v.getValue('approval') == 'approved'
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 01:35 AM
hi James,
i want to see the state of all the approvals from sysapproval_approver for given RITMs
Now there can be group approvals & manager approval ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 02:30 PM
You can try the following:
var ap = new GlideRecord('sysapproval_approver');
ap.addEncodedQuery('sysapproval.numberINRITM8513815,RITM8513711');
ap.query();
while (ap.next()) {
gs.log(ap.state);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 08:27 PM
I agree with @James Chun
Please use approval field available OOTB on RITM table to determine if RITM was approved or not
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader