- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2016 11:05 AM
I have the following business rule on a table.
function onAfter(current, previous) {
//This function will be automatically called when this rule is
var gr = new GlideRecord('u_safety_events');
gr.get(current.getValue('u_safety_event_number'));
gr.u_total_cost_confirmed = true;
gr.update();
This does not update the table. I test the getValue('u_safety_event_number') using ctrl, shift, alt, j and the sys_id returned is correct.
The business rule debugging doesn't shed any light on the issue:
14:03:25.411: Execute after update business rules on u_safety_events_property_loss:SPL0001064 before engines (order <1000)
14:03:25.411: ==> 'Update Total Confirm on parent' on u_safety_events_property_loss:SPL0001064
14:03:25.421: <== 'Update Total Confirm on parent' on u_safety_events_property_loss:SPL0001064
14:03:25.421: Finished executing after update business rules on u_safety_events_property_loss:SPL0001064 before engines (order <1000)
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 06:46 AM
The business rule works when I run it onBefore instead of onAfter:
function onBefore(current, previous) {
var intConfirmed;
if(current.getValue('u_total_cost_confirmed') == 'Yes'){
intConfirmed = "true";
}else{
intConfirmed = "false";
}
var gr = new GlideRecord('u_safety_events');
gr.get(current.getValue('u_safety_event_number'));
gr.u_total_cost_confirmed = intConfirmed;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2016 11:12 AM
Use current.u_safety_event_number.
I assume u_safety_event_number is a reference field. get is used with a sys_id or a ('field', 'field_value'). The reference field should be the sys_id, so a plain current.u_safety_event_number should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 06:46 AM
The business rule works when I run it onBefore instead of onAfter:
function onBefore(current, previous) {
var intConfirmed;
if(current.getValue('u_total_cost_confirmed') == 'Yes'){
intConfirmed = "true";
}else{
intConfirmed = "false";
}
var gr = new GlideRecord('u_safety_events');
gr.get(current.getValue('u_safety_event_number'));
gr.u_total_cost_confirmed = intConfirmed;
gr.update();
}