- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 05:18 AM
Hi Team
I'm working on a requirement where I need to prevent the submission of a CIR if the field it_fun_org is empty. The challenge is that this field is read-only on the form. This field is Currently populated based on Business application
Field Name : it_fun_org ( reference type : Business_app)
I want to restrict form when the it_fun_org field is empty.
Please help me how can i achieve this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 06:09 AM
try this
function onSubmit() {
var itFunOrg = g_form.getValue('it_fun_org');
if (itFunOrg == '' || itFunOrg == undefined) {
g_form.showFieldMsg('it_fun_org', 'IT Functional Org must be populated before submission.', 'error');
return false; // Prevent submission
}
return true;
}
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
06-23-2025 05:25 AM
it makes sense to stop submission if you expect agent to enter something in it.
But since it's readonly agent can't enter.
The code from where you are auto populating, you can do this
1) if auto population works and you are able to set value then set it and make it readonly
2) if it couldn't be populated, make it mandatory so that agent selects it and can't submit with that field as empty
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
06-23-2025 05:26 AM
Hey @JVINAY ,
You can use onSubmit client script to abort submission of form.
example code =>
function onSubmit() {
var reqVal = g_form.getValue('it_fun_org');
if (!reqVal) {
return false;
}
return true;
Please mark this answer helpful if it solves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 05:52 AM
HI @AyushKumarM
I have written the code below, but it's not working. If the field is empty, the form still gets submitted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 06:09 AM
try this
function onSubmit() {
var itFunOrg = g_form.getValue('it_fun_org');
if (itFunOrg == '' || itFunOrg == undefined) {
g_form.showFieldMsg('it_fun_org', 'IT Functional Org must be populated before submission.', 'error');
return false; // Prevent submission
}
return true;
}
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