- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2024 06:04 PM
I want to run a server-side script using a client script on a UI page.
I know how to call a script include from a client script, but is it possible to call code written in a UI page's processing script from the UI page's client script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 09:34 AM
Hi @bonsai ,
For using direct server side logic in UI page, ServiceNow allows us to write a code in jelly script as below.
<g:evaluate>
var userRoles = new GlideRecord('sys_user_has_role');
userRoles.addQuery('user','${jvar_user_id}');
userRoles.query();
</g:evaluate>
There are 2 versions of the jelly script in the platform. Please refer to existing UI pages for more details.
My recommendation would be to avoid the jelly script if it is not much of worth.
---------------------------------------------------------------------------------------------------
Please mark my answer as helpful/correct if it resolves your query.
Thanks,
Nilesh Wahule
---------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 07:03 PM
there are 2 ways
1) within client script of UI page use GlideAjax
OR
2) run server side script within processing script of UI page. remember for this to work you need to use <g:ui_form> and need to submit the form so that controls goes to UI page processing script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2024 04:03 PM
Hello @bonsai
UI page's processing script runs when the form is submitted, meaning it operates server-side after the client-side processing. To make a server-side call within a form, you should use GlideAjax.
GlideAjax allows you to call a Script Include from a client script, enabling you to run server-side logic while still interacting with the client-side form.
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 07:03 PM
there are 2 ways
1) within client script of UI page use GlideAjax
OR
2) run server side script within processing script of UI page. remember for this to work you need to use <g:ui_form> and need to submit the form so that controls goes to UI page processing script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 08:14 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2024 08:57 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2024 04:03 PM
Hello @bonsai
UI page's processing script runs when the form is submitted, meaning it operates server-side after the client-side processing. To make a server-side call within a form, you should use GlideAjax.
GlideAjax allows you to call a Script Include from a client script, enabling you to run server-side logic while still interacting with the client-side form.
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar