how to automatic set Yes/No field as no in sc_task table for 1 catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 07:21 AM
Hi All,
I have below requirement...
in the related list of sc_task table there are multiple yes/no field. I wanted to mark those field as NO when state is closed. but these is only for 1 catalog item not for global. kindly let me know how to do it.
Thanks & Regards
KP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 08:46 AM
Hello @keval3
You can meet your requirement with the help of business rules.
Steps:
Create a Business Rule on the sc_task table:
- Trigger: Before update
- Condition: Leave blank (we'll handle the condition in the script)
- Advanced: Check the "Advanced" checkbox to add a script.
Script:
// Check if the state is 3, 4, or 7(modify as per your requirement) and the catalog item matches the specific item
if ((current.state == 3 || current.state == 4 || current.state == 7) &&
current.parent.cat_item == 'catalog_item_sys_id') { // Replace with your catalog item's sys_id
// Set the Yes/No fields to "No"
current.yes_no_field_1 = false; // Replace with your field names
current.yes_no_field_2 = false;
current.yes_no_field_3 = false;
// Add more fields as needed
}
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2025 06:18 AM
you can have after update BR on sc_task
Condition: State Changes to [Close Complete] && current.request_item.cat_item.name == 'Your Catalog Item Name Here'
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var ritmRec = current.request_item.getRefRecord();
ritmRec.variables.variable1 = 'No'; // give correct choice value and variable name here
ritmRec.variables.variable2 = 'No'; // give correct choice value and variable name here
ritmRec.update();
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 09:07 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2025 08:04 AM
Hi @keval3 ,
Please create After Update BR, and add below code
if ((current.state == 3 || current.state == 4 || current.state == 7) && current.parent.cat_item == 'catalog_item_sys_id') {
var currentRITM = current.request_item.getRefRecord();
currentRITM.variable.variableName_1 = false; // Replace with your field names
currentRITM.variable.variableName_2 = false;
currentRITM.variable.variableName_3 = false;
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak