- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2020 05:22 AM
I need to push field as mandatory based on the ui view . So i want to make the validation based on URL using window.location.href.contains(). So if the url belongs to second UI page then make field as mandatory? But i am trying its not working ! so can any expert help
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2021 02:22 AM
Would you mind marking my response as correct & helpful if I am able to resolve your query?
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
07-06-2020 05:28 AM
You can achieve this by combining both your client side code inside the UI action.
This article has a good example: https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
First you call your client-side validation and then pass to server side to execute.
Hope this helps.
If this was helpful or correct, please be kind and click appropriately!
Michael Jones - Proud member of the CloudPires Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2020 05:40 AM
Hi,
please use this and check in onload client script
function onLoad(){
// give here the value to search
if(top.location.href.indexOf('value to search') >= 0){
g_form.setMandatory('field', true); // give here the field name
}
}
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
07-06-2020 06:09 AM
Thanks its working on client ....
Will it work in script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2020 06:15 AM
Hi,
If you require in script include then this should give you the URL in server side
I won't recommend this if something you can achieve just using client script.
var url = gs.action.getGlideURI().toString();
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
07-08-2020 07:59 AM