How to pass previous values from business rules to script action in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2025 05:03 AM
I am unable to pass previous values to script action from Business Rules. could you please help me.
Many thanks,
Raghuveer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2025 06:19 AM
Post your attempt. Have you logged the previous value in the Business Rule to ensure it is captured correctly before looking for it elsewhere?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2025 06:26 AM
Hi @18wj1a05d2,
You can pass previous values from a Business Rule into a Script Action, but not automatically - you must pass them explicitly using Event parameters. A script action only receives the values that you send through the gs.eventQueue() call.
Best regards,
Renat Akhmedov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2025 06:39 AM
yes it's possible to send via event parm1 or event parm2
something like this
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
gs.eventQueue('eventName', current.state, previous.state);
})(current, previous);
Then in script action you can grab this
var currentValue = event.parm1;
var previousValue = event.parm2;
An Examination of gs.eventQueue
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2025 08:32 AM
Hi @18wj1a05d2 ,
To pass previous values from a Business Rule to a Script Action, you must send them through event parameters, because Script Actions cannot access previous directly.
Business Rule
gs.eventQueue( 'your.custom.event', current, current.your_field, // param1 previous.your_field // param2 );
Script Action
var currentValue = event.parm1; var previousValue = event.parm2;
Script Action now receives both current and previous values.
If my response helped, please mark it as the accepted solution so others can benefit as well.