Submit or Insert/Insert and Stay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 04:56 PM
Hi,
I wolud like to run a script(like clearing fields) on Users form when pushing "Insert" or "Insert and Stay". However, I do not want to run it when "Submit", "Save", or any Update.
Is it available? Could you please advise how to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 12:15 AM - edited 08-21-2024 12:27 AM
Hey,
In ServiceNow, you can achieve this by creating a client script that runs on the insert
event of the form, but not on the update
event.
Here's an example of how you can do this:
-
function onLoad() {
// Get the form object
var form = g_form;// Check if the form is being inserted (not updated)
if (form.getAction() == 'insert') {
// Clear the fields you want to clear
form.clearValue('field1');
form.clearValue('field2');
// ...
}
}
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 12:23 AM
Hi @ao7
What is your business case here?
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************