Unable to get previous value using BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 11:45 PM
Hello,
I am trying to perform some actions based on new value and previous value of BU code field present on user table.
I created after(update on some field value change) BR on user table and writing below code. However I am getting blank value in logs. Please suggest.
if (current.u_sf_business_unit_code.changes()) {
var prevBU = previous.u_sf_business_unit_code;
var newBU = current.u_sf_business_unit_code;
gs.log('previous BU', prevBU);
gs.log('newBU ', newBU);
try {
gs.log('BU changes ');
sn_fd.FlowAPI.getRunner().subflow('global.sml_internal_mover__business_unit').inBackground().withInputs(inputs).run();
} catch (ex) {
var message1 = ex.getMessage();
gs.error(message);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 01:53 AM
I made it before BR. however it is still returning me blank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:24 AM
Please comment the first if loop and and check what the previous object contains by adding a infomessage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 01:08 AM
In After Business Rule, Previous value will be blank because the value is already updated in the database which means it is the current value.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:01 AM
Can you share screenshot of your BR, your user table field on the form and how the logs look like.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:14 AM
Can you try this and help me with the logs-
if (current.u_sf_business_unit_code.changes()) {
var prevBU = previous.u_sf_business_unit_code;
var newBU = current.u_sf_business_unit_code;
gs.log('Previous BU: ' + prevBU);
gs.log('New BU: ' + newBU);
try {
gs.log('BU changes detected, initiating subflow.');
var inputs = {}; // Define and populate your inputs object here
sn_fd.FlowAPI.getRunner().subflow('global.sml_internal_mover__business_unit').inBackground().withInputs(inputs).run();
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
}
Please mark it helpful and correct if it works.
Regards,
Amit