- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2017 12:35 PM
I have two custom Tables (u_training_class) & (u_attendee). Attendee is a Related List on the Training Class table.
I have a reference field (to sys_user) (u_trainer) on Training Class table where the Trainer will add their name.
I have a reference field (to sys_user) (u_trainer) on Attendee table that needs to get the Trainer value entered on the Classes table.
NOTE: I can't show the u_training_class.u_trainer on the Attendee table because the required Survey cannot access the related field, so I need to write the value from Class to Attendee using two separate fields (u_trainer) reference fields.
I have an Insert BR that writes the value to the Attendee record when a a new Attendee is added and the Trainer name already exists on the Class table. That's working fine.
But my update Business Rule is not working if the Trainer name is changed on the Training Class table or if a Trainer name is added to the Training Class table and related Attendee records already exist. In either case, I need to update all of the Attendee records to the added or changed Trainer name entered on the Training Class table. I have the following BR.
BR added to u_attendee table
When = after
Insert = true, Update = true
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('u_training_class');
gr.addQuery('u_trainer', current.getValue());
gr.query();
while (gr.next()){
gr.u_trainer = current.u_trainer;
gr.update();
}
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2017 12:59 PM
The business rule should be on u_training_class table as data is getting updated on class not on attendee table
Below is the script
please update the Training class field that is on attendee table
var gr = new GlideRecord('u_attendee');
gr.addQuery('u_training_class_reference_field', current.sys_id);
gr.query();
while (gr.next()){
gr.u_trainer = current.u_trainer;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2017 01:15 PM
Thank you! Too much going on today.....Appreciate your help.