- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 12:13 PM
Hi All,
We have a requirement to stop form submission for all tickets if users selected InValid CIs. We have Affected CIs(cmdb_ci) field on task table and IT owner field on CIs.
If IT owner field is empty in that case users should not be able to submit the form.
We have written below script using OnSubmit Client script but its not working, users are able to submit the form.
Please assist.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 12:44 PM
Try with below script, it will work, tested on my PDI, the issue was with async call on onSubmit action.
function onSubmit() {
if (g_scratchpad.isFormValid) {
return true;
}
var actionName = g_form.getActionName();
var ci = g_form.getReference('cmdb_ci', callBack);
function callBack(ci) {
var itOwner = ci.u_it_owner;
if (itOwner == "") {
alert(' IT Owner is empty');
g_form.addErrorMessage("IT owner value for selected CIs is empty, please IT owner value gets updated or select another CIs");
return false;
}
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
}
return false;
}
Thanks,
Harsh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 12:22 PM
Hi @Mukesh Singh - You can try to debug this by adding alert() .
try with below script and see what are you getting in alert .
function onSubmit() {
//Type appropriate comment here, and begin script below
var ci = g_form.getReference('cmdb_ci', callBack);
function callBack(ci) {
var itOwner = ci.u_it_owner;
alert( ' IT Owner is ' + itOwner );
if (itOwner == "") {
alert( ' IT Owner is empty' );
g_form.addErrorMessage("IT owner value for selected CIs is empty, please IT owner value gets updated or select another CIs");
return false;
}
}
}
Check what are you getting in those two alert ?
Thanks,
Harsh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 12:33 PM
Hi Harsh,
I have tried to change request with it owner field empty and got both alert message.
alert 1 = IT Owner is
alert 2 = IT Owner is empty
Once clicked 'Ok' on alert messages, change request got created.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 12:44 PM
Try with below script, it will work, tested on my PDI, the issue was with async call on onSubmit action.
function onSubmit() {
if (g_scratchpad.isFormValid) {
return true;
}
var actionName = g_form.getActionName();
var ci = g_form.getReference('cmdb_ci', callBack);
function callBack(ci) {
var itOwner = ci.u_it_owner;
if (itOwner == "") {
alert(' IT Owner is empty');
g_form.addErrorMessage("IT owner value for selected CIs is empty, please IT owner value gets updated or select another CIs");
return false;
}
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
}
return false;
}
Thanks,
Harsh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 12:55 PM
Thank you Harsh. Its working now.