- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @AfifU !!
Runs first: the onSubmit Client Script
Value that is finally saved: the value set by the Before Business Rule
Explanation:
When a user submits the Incident form, the onSubmit Client Script runs in the browser first. Any field values it sets are included in the data sent to the server.
After the data reaches the server, the Before Business Rule runs before the record is written to the database.
If the Business Rule updates the same field, it overwrites whatever value was set by the client script.
Result:
The Before Business Rule’s value is what gets saved to the record.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Your Client script is executed first, And then Business rules will run
refer this article:
If my response helps, please mark it as helpful and accept as solution
Warm Regards
Sumit Yadav
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Order of execution:
1) onSubmit Client Script runs first (browser / UI)
2) Before Business Rule runs next (server)
Final value saved is value set by the Before Business Rule
Because server-side logic always wins over client-side logic before the record is written to the data
you can also Refer to this image which contains all the script Execution order
🔴IF you Find this helpful then please give thumbs up👍👍
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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 weeks ago
Hi @AfifU,
A Client Script runs on the client side and executes based on user actions such as form load, change, or submit. It depends on user interaction and an onSubmit Client Script runs just before the form is submitted to the server.
A Business Rule is a server-side script that runs in the backend and does not depend on user interaction. A Before Business Rule runs before the record is saved to the database, while After and Async rules run later.
Therefore, Client Scripts run first on the client side, and once the request reaches the server, Business Rules execute before the data is committed to the database.
If you find my answer helpful, please mark it as Correct and Helpful 😊.
Regards,
Soham Tipnis
ServiceNow Developer || Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @AfifU !!
Runs first: the onSubmit Client Script
Value that is finally saved: the value set by the Before Business Rule
Explanation:
When a user submits the Incident form, the onSubmit Client Script runs in the browser first. Any field values it sets are included in the data sent to the server.
After the data reaches the server, the Before Business Rule runs before the record is written to the database.
If the Business Rule updates the same field, it overwrites whatever value was set by the client script.
Result:
The Before Business Rule’s value is what gets saved to the record.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Your Client script is executed first, And then Business rules will run
refer this article:
If my response helps, please mark it as helpful and accept as solution
Warm Regards
Sumit Yadav
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Order of execution:
1) onSubmit Client Script runs first (browser / UI)
2) Before Business Rule runs next (server)
Final value saved is value set by the Before Business Rule
Because server-side logic always wins over client-side logic before the record is written to the data
you can also Refer to this image which contains all the script Execution order
🔴IF you Find this helpful then please give thumbs up👍👍
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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
