- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 10:28 AM
I have come to a road block here.I have a onAfter business rule which entirely depends on current.operation() and it is null. The business rule is firing.The first gs.info message logs:Business rule running: null 4f65a2676f9a0200b5919e0cbb3ee43b. Does not go beyond that.I am also attaching the image of business rule.Any direction will be helpful.I am on Fuji Patch 7.
function onAfter(current, previous) {
//This function will be automatically called when this rule is processed.
gs.info("Business rule running: {0} {1}", current.operation(),current.sys_id);
if( current.operation() == "insert" ) {
gs.log('Insert rule running:', 'Location Sync Remote App Table');
insertToRemoteTable(current);
}
else if( current.operation() == "update") {
gs.log('Update rule running:', 'Location Sync Remote App Table');
updateOnRemoteTable(current);
}else if ( current.operation() == "delete") {
gs.log('Delete rule running:' , 'Location Sync Remote App Table');
deleteFromRemoteTable(current);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 12:16 PM
I don't believe that operation is available for an 'after' business rule.
I would suggest creating two separate business rules, with the insert and update only checked respectively.
(Other option is make it a before, but it could be a performance hit.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 11:54 AM
Thanks for your interest in my question.I am not creating this BR as part of a scoped application.It is for OOB Location table(cmn_location).The table was available for me to select on create Business Rule form, 'Table' field. So I guess the table is in same scope???
Tried changing to gs.info.Did not help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 12:12 PM
Okay..Last try and this should work. I have tried on demo and it works.
function onAfter(current, previous) {
//This function will be automatically called when this rule is processed.
gs.addInfoMessage('Business rule running:'+current.sys_id);
if( current.operation() == "insert" ) {
gs.addInfoMessage('Business rule running:'+current.operation());
insertToRemoteTable(current);
}
else if( current.operation() == "update") {
gs.addInfoMessage('Business rule running:'+current.operation());
updateOnRemoteTable(current);
}else if ( current.operation() == "delete") {
gs.addInfoMessage('Business rule running:'+current.operation());
deleteFromRemoteTable(current);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 12:16 PM
I don't believe that operation is available for an 'after' business rule.
I would suggest creating two separate business rules, with the insert and update only checked respectively.
(Other option is make it a before, but it could be a performance hit.)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 12:17 PM
But I do remember using current.operation() in a after rule. Did something change in the latest release?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 12:19 PM
Hi Robert,
This will work. Please correct me if I m wrong.