How to know if related list is not empty and automatically update the field on the parent form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 11:34 PM
Hi!
We have a requirement where we want to query the related list in Table_1 and if there' at least one record in Related_List_1, the Select Box field value will be changed in Table_1 form
Sample Details:
table_1 = is the current form
relate_list_1 = is the related list on the Table_1
Type = is the select box field (Choices: One , Two)
Scenario:
If the related_list_1 has at least 1 record in table_1 form, the Select box = 'One'
Thank you in Advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 09:42 PM
Hi @ss123 ,
When I check the board card related list then it has 'board' as a reference field which refers to the vbt board table.
Modified script as :-
(function executeRule(current, previous /*null when async*/ ) {
var vtbcard = new GlideRecord('vtb_card');
vtbcard.addQuery('board', current.sys_id);
vtbcard.query();
if (vtbcard.next()) {
current.setValue('u_choice_2', 'no');
} else {
current.setValue('u_choice_2', 'yes');
}
})(current, previous);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 10:41 PM
I used the modified script you provided, and still not working ..
Both records ( created from module / created from vtb) " u_choice_2" value is "Yes"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 10:44 PM
Hi @ss123 ,
Share me your snapshot of When to Run tab of BR. also at the time of insertion is there any task automatically assigned to VTB record ?
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 11:01 PM
Here's the screenshot. Also, there's no task automatically assigned to VTB record when created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 11:31 PM
Hi @ss123 ,
Okay, I got confused with tables and fields. Writedown above BR on 'vbt_card' table
(function executeRule(current, previous /*null when async*/ ) {
var vtbtask = new GlideRecord('vtb_task');
vtbtask.addQuery('sys_id', current.task);
vtbtask.query();
if (vtbtask.next()) {
vtbtask.setValue('u_choice_2', 'no');
} else {
vtbtask.setValue('u_choice_2', 'yes');
}
vtbtask.update();
})(current, previous);