- 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-08-2020 08:16 AM
Hi,
From where your script include is getting called?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 10:24 AM
from UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 11:06 AM
If these are standard change templates, fields are getting mandatory from client script 'Check Template Values'. Its onsubmit client script. Find a part of script which is making mandatory.
function isMandatoryFieldsSet(q) {
var unfilledValues = ' ';
var mandatory = sncStdChg.mandatory;
/*From Here add your customization.
if(location.href.toString.indexOf('value')>=0)
{
mandatory.push('Your field');
}* /
if (mandatory) {
for (var i = 0; i < mandatory.length; i++) {
var m = mandatory[i];
if (q) {
var idx = q.names.indexOf(m.name);
if (idx === -1 || q.vals[idx] === '')
unfilledValues = unfilledValues + m.label + ', ';
} else {
unfilledValues = unfilledValues + m.label + ', ';
}
}
}
No need to make changes to the script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 07:49 AM
Hi maheshn,
It doesnt seems to be working as it is custom table.
can you tell how to check url in script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 08:16 AM
Hi,
Are you determining fields to be set as mandatory from the script include?
Can you explain the process what you are doing?
top.location won't work in script include code
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader