Required Modification in Existing fix script of RITM Stages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 01:01 AM
Actually i need modification in existing script only.
Requirement: In existing script need to add that if approval is requested then no need to pick up that RITM in list ,also required list of RITMs whose stages are Waiting for Approval (value 1)and fulfillment(value 2)
please refer below URL and guide me to add stages and approvals in existing script
Solved: To pick RITM which are in open state once after th... - ServiceNow Community
var arr = []; var gr = new GlideRecord("sc_req_item"); gr.addEncodedQuery("state=1"); // state is open gr.query(); while(gr.next()) { var closedCount = 0; var taskRec = new GlideRecord("sc_task"); taskRec.addQuery("request_item", gr.sys_id); taskRec.query(); var totalCount = taskRec.getRowCount(); while(taskRec.next()){ if(taskRec.active.toString() == 'false'){ closedCount++; } } if(closedCount == totalCount && totalCount != 0){ // if count is same then all tasks are closed then push RITM number in array arr.push(gr.getValue('number')); } } gs.print(arr.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 02:31 AM
Hi @thomas94 ,
You can just update the encoded query as below,
gr.addEncodedQuery("stateIN-5,1,2^stageINfulfillment,waiting_for_approval^approval!=requested^ORapproval=");
I have updated the script aswell,
var arr = [];
var gr = new GlideRecord("sc_req_item");
gr.addEncodedQuery("stateIN-5,1,2^stageINfulfillment,waiting_for_approval^approval!=requested^ORapproval="); // state is open
gr.query();
while(gr.next()) {
var closedCount = 0;
var taskRec = new GlideRecord("sc_task");
taskRec.addQuery("request_item", gr.sys_id);
taskRec.query();
var totalCount = taskRec.getRowCount();
while(taskRec.next()){
if(taskRec.active.toString() == 'false'){
closedCount++;
}
}
if(closedCount == totalCount && totalCount != 0){
// if count is same then all tasks are closed then push RITM number in array
arr.push(gr.getValue('number'));
}
}
gs.print(arr.toString());
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 04:24 AM
Hi Swathi
Thank you for providing the script but unfortunately it is not giving the expected result , can you please provide the output of this script because for me it is not giving any output also if possible can you give the another script along with the expected result then it will be grateful for me, Thanks
Regards,
Vardan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 04:41 AM
Did you copy the the query from your instance ? as i have mentioned above ? if yes please share the script which you have used
Thanks
Swathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 02:16 AM
Hi Swathi
Please check below script . it is not working currently but now I need the same which I have added in encoded query but instead of getting the approval field in query can you write a script like on approval table similar to sc_task ?
Kindly provide ASAP , It is urgent.
...............