Please provide the Script to update State and Stage for Request and Requested Item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2023 08:10 AM
Please provide the Script to update State and Stage for Request and Requested Item of around 1500 RITM?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2023 08:53 AM
what is your query for 1500 items? you can add the encoded query and execute below:
var req = new GlideRecord('sc_request');
req.addEncodedQuery(' '); // add your encoded query
req.query();
while(req.next())
{
var item = new GlideRecord('sc_req_item');
item.addQuery('request',req.sys_id);
item.query();
while(item.next())
{
item.state = ""; //add item state backend value
item.stage=""; // add item stage backend value
item.update();
}
req.state=""; //add request state backend value
req.stage="";//add request stage backend value
req.update();
}
Note: All scripts should be tested before executing in prod.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 10:38 AM
@VIKAS45 do mark the relevant answer correct to close the thread.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2023 09:01 AM
var req = new GlideRecord('sc_request');
// req.addQuery('some_field', 'some_field_value'); // filter condition
req.query();
while (rec.next()) {
rec.stage = 'field_value'); // 'fullfilment', 'delivery', 'waiting_for_approval'
rec.update();
}
var reqItem = new GlideRecord('sc_req_item');
// reqItem.addQuery('some_field', 'some_field_value'); // filter condition
reqItem.query();
while (recItem.next()) {
recItem.stage = 'field_value'); // 'fullfilment', 'delivery', ...
recItem.update();
}
I suspect you'll encounter some workflow problems for those records or other un-anticipated behavior. but the above is a starting point if you want to go through with that. Use values for 'stage' that are defined in your instance.