Client script containing jquery working in nativeUI but not in workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 11:04 AM - edited 11-21-2023 11:48 AM
I trying to set default date time picker value while form loading through client script, it is working in native but not in workspace, I have tried all suggestion which were suggested online like setting isolate script to true or using noconflict but none worked.
this is the code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 01:16 PM - edited 11-21-2023 01:18 PM
Hi @aanaveni
JellyScript will not work in Workspace.
Native UI supports JellyScript but Workspace doesn’t.
Find some alternate method/way to get your requirement fulfilled on Workspace.
Thanks!
Please mark this response as correct and helpful ✔️👍
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 01:37 PM
I have searched almost every source, only way to make this happen sadly is using jelly script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 07:44 PM
HI @aanaveni ,
I trust you are doing great.
The issue you're encountering with setting the default date and time picker value in the ServiceNow workspace, despite it working in the native interface, is likely due to the differences in how the workspace and the native interface handle scripts. As Shubham Singh pointed out, JellyScript, which is typically used in the native UI of ServiceNow, doesn't work in the workspace environment.
Instead of relying on direct DOM manipulation with jQuery, consider using ServiceNow's built-in client script functionalities. You can use the g_form
API to set field values and control form behaviors.
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 12:03 PM
Hello Amit,
I tried using following code using g_form,
function setDatePickerTime(field) {
//Attach an event listener to set default time value for date picker
Event.observe($(g_form.getControl(field).id).next('a'), 'click', function() {
setTimeout(\"$('GwtDateTimePicker_hh').value = '00';$('GwtDateTimePicker_mm').value = '00';$('GwtDateTimePicker_ss').value = '00';\",0);
});
}, but it is not accepting $.