script on incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
An Incident is updated from the UI. There is:
an onSubmit Client Script that sets a field value, and
a Before Business Rule on the same table that also updates that field.
Question:
Which one runs first, and which value is finally saved to the record?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @AfifU ,
First, the Client Script executes on form submission and updates the field values on the client side. Then, before the record is stored in the database, the Before Business Rule executes on the server side. Although both scripts run, the Business Rule determines the final value that gets saved in the database.
If this helps you then mark it as helpful and accept as solution.
Regards,
Aditya,
technical consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
it's an easy question.
the final outcome will be based on login in Before Business rule
💡 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @AfifU ,
The onSubmit script runs first on the client and Before BR runs next before data gets stored in the server
the Value set By the BR will be saved.
This pic should help you
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @AfifU ,
Just a simple explanation to make things clear:
When a record is updated from the UI, ServiceNow executes scripts in the following order:
onSubmit Client Script
Runs first
Executes on the client side (browser)
Sets or modifies field values on the form
These values are then sent to the server as part of the submit request
Before Business Rule
Runs after the request reaches the server
Executes on the server side
Runs just before the record is written to the database
Can validate or override any field values
Final Result
The value set in the Before Business Rule is what gets saved to the record.
This is because server-side scripts always have the final authority, ensuring data integrity and consistency
Shashank Jain