- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2024 01:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2024 01:19 AM
Hi @vardhan3 ,
Could you please elaborate your requirement ?
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2024 04:59 AM - edited ‎03-18-2024 05:01 AM
@vardhan3 i got it, could you please try below code let me know if this work or not ?
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());
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
‎03-20-2024 04:05 AM
Hi Swathi,
Can I get the same script for Stages of RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 04:15 AM
@vardhan3 , as this thread is closed could you please raise a new question and tag me in that ? and please explain the requirement in detail
Thanks
Swathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 06:03 AM
Hi Swathi,
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2024 02:32 AM
Hi Swathi,
Our requirement is we need the list of RITM numbers whose state is Open, WIP, Pending but all sc task should be closed. can you please provide the script?
I have prepared the below script but in the final array I haven't getting correct list of RITM Numbers.
.............................
var test = [];           
var test1 = [];           
var gr = new GlideRecord("sc_task");     
gr.addEncodedQuery("parent.active=true^active=false");     
gr.query();           
while (gr.next()) {           
if (gr.request_item.active ==true) {     
test.push(gr.request_item.number);     
}              
}              
gs.print("active RITM's with close complete SC tasks: "+test);
var gr1 = new GlideRecord("sc_task");     
gr1.addEncodedQuery("parent.active=true^active=true");                 
gr1.query();           
while (gr1.next()) {  
if(gr1.request_item.number!=""){         
test1.push(gr1.request_item.number);  
}  
}              
gs.print("RITM's with Open SC tasks: "+test1);  
test = test.filter(function(element) {     
return test1.indexOf(element) === -1;     
});              
gs.print("Final array: Open RITM with Closed SC Task " + test);