How to pass previous values from business rules to script action in servicenow
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
I am unable to pass previous values to script action from Business Rules. could you please help me.
Many thanks,
Raghuveer
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Pass Previous Values as Flow Inputs
In your Business Rule, explicitly pass the previous values as input variables to the flow:
Business Rule (Before/After Update):
javascript
(function executeRule(current, previous /*null when async*/) { // Store previous values in an object var previousValues = { state: previous.state.toString(), assigned_to: previous.assigned_to.toString(), priority: previous.priority.toString() // Add other fields you need }; // Trigger the flow with both current and previous values var inputs = { current_record: current.getUniqueValue(), table_name: current.getTableName(), previous_state: previousValues.state, previous_assigned_to: previousValues.assigned_to, previous_priority: previousValues.priority }; sn_fd.FlowAPI.getRunner().trigger('your_flow_sys_id', inputs); })(current, previous);
Then in your Flow Designer script action, access these as input variables:
javascript
inputs.previous_state inputs.previous_assigned_to
Hello i hope that can help
If you find this answer useful, please mark it as solution accepted/helpful
Massimiliano Micali
