- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 05:31 AM
Hello,
I have a UI Page with a g:ui-date jelly-tag. Is it possible to have an onChange function on this field? So that when you change the date, the function is called.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 06:56 AM
https://community.servicenow.com/community?id=community_question&sys_id=2c0fcba1dbdcdbc01dcaf3231f9619ae
This worked!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 05:38 AM
Not sure. Have you tried adding onchange="myFunction()" to your g:ui-date jelly-tag?
You could try add an event listener if your g:ui-date jelly-tag has an ID tag for example:
document.getElementById("your_id").addEventListener("change", onChangeFunction);
function onChangeFunction() {
//do what you want to do onChange
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 05:40 AM
Hi,
onChange atttribute won't work for <g:ui_date> tag
You can perform validation during submission.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 05:47 AM
Thanks, both. Where would you call the eventListener?
Is there a work-around for this? Can I pass the variable from the <g:ui_date> tag to a HTML tag (hidden input field?) which has an onChange attribute?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 05:52 AM
the event listener is client script, so you can put it in the Client script field on the UI Page.
But since it is a Jelly tag, I am not sure it will work. If you are able to pass it to a hidden input field, then both options ( "onchange=" and event listener) will definitely work for a regular input field.