ATF Server side script query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 12:55 AM
Hello Folks,
- We are trying to submit the catalogue via ATF. As this catalogue has mandatory attachment, we have approached REST steps to submit the catalogue.
- What we want to achieve via atf is :
Submit the catalogue > validate the REQ generated > validate the RITM generated > Approve the RITM > Open the sctask> close the sctasks generated.
- We have referred below article to submit the catalogue.
How to submit a catalog item using REST API - Support and Troubleshooting (servicenow.com)
- By below step we are able to submit the catalogue.
- In table 'sys_atf_test_result_step' we can find the RITM value in Response body.
- Query 1 : Do we find the REQ generated via atf test in REQ table ? ( From my observation is that we couldnt find it REQ table ).
- Query 2 : Can we achieve this (validate the REQ generated > validate the RITM generated > Approve the RITM > Open the sctask> close the sctasks generated.) via Run server side script step in atf? We need to pick up the REQ generated to be picked dynamically. If Yes, can you please provide me sample snippet to achieve this scenario ?
- Query 3 - Query 2 is Valid / feasible via ATF ?
I have been working on this issue past 1 week but not luck. Any input on this would be helpful.
Regards,
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 08:12 AM
Hi @Jayalakshmi
I don't know if this will work or not:
So after submitting the catalog, use Record query step for request table.
Add filter like created today , submitted by or some specific fields value that you used while creating the catalog.
after this you need to use Open existing record>>record query(dot walk).
This way you can open the created REQ.
For for other query you can use related list steps.
Mark Helpful/Solution 🙂
Regards
Shaqeel
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 10:39 AM
HI @Jayalakshmi ,
I trust you are doing great.
Yes, it is feasible to achieve your workflow using ATF, particularly with the "Run Server Side Script" step. Below is a simplified example of how you might script some of these steps.
// Assuming you have the RITM sys_id from the REST step's response
var ritmSysId = 'your_ritm_sys_id_here';
// Load the RITM record
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(ritmSysId)) {
// Validate RITM details as needed
// For example, check the state or any other field
var ritmState = ritmGr.getValue('state');
// Approve the RITM
ritmGr.setValue('state', '3'); // Assuming '3' is the approved state
ritmGr.update();
// Find related sc_tasks
var taskGr = new GlideRecord('sc_task');
taskGr.addQuery('request_item', ritmSysId);
taskGr.query();
while (taskGr.next()) {
// Open and immediately close each task, for example
taskGr.setValue('state', '4'); // Assuming '4' is the closed state
taskGr.update();
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi