Background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 11:40 PM
Hi Community,
How to write the fix script to set the yes/no variable as yes for the existing RITMS if the doallar amount value is greater than or equal to 100000 .
Thanks,
Manu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 11:48 PM - edited 02-13-2024 11:48 PM
// Query the RITMS table
var ritms = new GlideRecord('table_name');
ritms.addQuery('amount', '>=', 100000); // Filter records with amount greater than or equal to $100,000
ritms.query();
// Update yes/no variable for qualifying records
while (ritms.next()) {
ritms.yes_no = 'yes';
ritms.update();
gs.info('Updated RITM ' + ritms.number + ': Yes/No set to yes');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 11:50 PM - edited 02-14-2024 12:02 AM
Hi @Manu143
Below is the script that will update all the RITM variables to yes, just add the correct filter condition.
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('' , '');// Please add the correct query condition here.
grRITM.query();
while(grRITM.next()){
grRITM.your_variable_backend_value = 'yes';
grRITN.update();
}
Always mark the fastest solution provided as helpful if that resolves your query.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 11:57 PM
You can write below script in fix script :
// Define the condition for updating RITMs
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addEncodedQuery('dollar_amount >= 100000'); // validate the field database name
ritmGr.query();
while (ritmGr.next()) {
ritmGr.setValue('yes_no_variable', 'yes'); // validate yes_no_variable database name
ritmGr.update();
}
gs.log("Fix script executed. Updated 'yes/no' variable for RITMs with dollar_amount >= 100000.");
Kindly mark helpful/accepted if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 12:04 AM
var gr = new GlideRecord('sc_req_item');
gr.addQuery('amount >= 100000'); // considering the field name is amount
gr.query();
while (gr.next()) {
gr.fieldname_of_dollar_field = 'yes';
gr.update();
}