- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025 11:41 PM
I have a requirement and I want to execute a OnChange client script when the form loads. Is this possible? Any help would be much appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 09:38 PM
Yes Buddy, It is possible to use OnChange Client script at OnLoad.
I am assuming that the task(For Onload and Onchange) is same, then you simply remove isLoading from line 2 and it will work same for load and change.
Please mark my response correct and helpful, if it helps you.
Please reply if any issue happens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 06:15 AM
Hi @Arishmit
No mate, you cant do that technically.
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 09:38 PM
Yes Buddy, It is possible to use OnChange Client script at OnLoad.
I am assuming that the task(For Onload and Onchange) is same, then you simply remove isLoading from line 2 and it will work same for load and change.
Please mark my response correct and helpful, if it helps you.
Please reply if any issue happens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 09:43 PM
yes, you can execute an OnChange client script when the form loads by programmatically triggering the onChange event. Use a g_form.setValue() followed by a g_form.getValue() to simulate a change in the field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === oldValue) {
return;
}
console.log('Field changed:', newValue);
}
if (!g_form.isNewRecord()) {
var value = g_form.getValue('field_name');
g_form.setValue('field_name', value);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 09:48 PM
Hello @Arishmit
Yes, you can do so.
Check the video https://youtu.be/uMGYjVVbHRo?si=fUsRNACc7kBrvuNN
https://youtu.be/PoTEa5ohLHo?si=WbnRKt-wUm0oGDzj
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.