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
3 hours ago
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
2 hours ago
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
2 hours ago
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
2 hours ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
