- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 02:05 AM
Hi Everyone,
I have a code for making single requests to make active false by using Background scripts but for making multiple requests to make active false what i need to add in this below query.
Please suggest me on below code.
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', ##789);
gr.setLimit(1);
gr.query();
if(gr.next())
{
gr.setValue('active','false');
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}
Thanks,
Midde.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 02:12 AM
Hello ,
Please try this
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQueryQuery('copy the query from filter');
gr.query();
while(gr.next())
{
gr.setValue('active','false');
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}
Example
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQueryQuery('assigned_to=a8f98bb0eb32010045e1a5115206fe3a^active=true');
gr.query();
while(gr.next())
{
gr.setValue('active','false');
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Sagar Tajane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 02:07 AM
Try below code:
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', ##789);
gr.setLimit(1);
gr.query();
while(gr.next())
{
gr.active = false;
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 02:08 AM
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('add encoded query here');
gr.query();
while(gr.next()) //use while to loop through the results
{
gr.setValue('active','false');
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 02:11 AM
Hi Midde,
Replace
gr.addQuery('number', ##789);
with
gr.addEncodedQuery('pass_in_the_query');
& also remove gr.setLimit(1);
All you need is to apply necessary filter on RITM & then right click the filter end
Then paste the query in the pass_in_the_query part.
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 02:12 AM
Hello ,
Please try this
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQueryQuery('copy the query from filter');
gr.query();
while(gr.next())
{
gr.setValue('active','false');
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}
Example
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQueryQuery('assigned_to=a8f98bb0eb32010045e1a5115206fe3a^active=true');
gr.query();
while(gr.next())
{
gr.setValue('active','false');
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Sagar Tajane