Restrict the form submission if the record is already there in the table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:33 AM
Hi All,
Having a requirement that,
we have a catalog form through that we are trying to insert the record in the software model table- cmdb_software_product_model
we have below fields as required.
in the above image we have the sample data in the fields.
we need to restrict the form submission if the record with the same parameters exist in the software model table.
Throw an alert and restrict the form submission.
we need to validate the three parameters in the software table like Product, publisher, version.
if we can validate the entered data to table record data then if exist restrict the form submission.
Any suggestion to achieve this..
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:36 AM
is this a catalog item or record producer?
If it is a record producer, you can add current.setAbortAction(true) in the record producer script.
If it is a catalog item, you may need to write an onsubmit and do glideajax or allow user to submit and later reject it and notify the user that the record already exists.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:40 AM
Hi @SanjivMeher
Thanks for your swift response.
its a catalog item we are having.
is there any reference of the onSubmit script to get it validated of the three fields on the form to the table.
Any suggestions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:50 AM
Something like this
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579
Refer this article too
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:41 AM
Hi @Community Alums ,
Please change the below script according to your query:
if (g_form.getValue('oss_gov_package_registry') == 'npm' || g_form.getValue('oss_gov_package_registry') == 'nuget') {
alert('inside npm :' + g_form.getValue('oss_gov_package_registry'));
//var ga1=new GlideAjax('InsertLicenseRecord');
ga1.addParam('sysparm_name', 'isRecordExistInOSSLibrary');
ga1.addParam('sysparm_packageName', g_form.getValue('package_name'));
ga1.addParam('sysparm_packageRegistry', g_form.getValue('oss_gov_package_registry'));
ga1.addParam('sysparm_packageVersion', g_form.getValue('oss_gov_version_number'));
ga1.getXMLWait();
var recordExist =ga1.getAnswer();
if (recordExist == "true") {
alert('Record is already exist so please submit the record with different value');
return false;
}
}
Script Include :
var ValidateOSSLibraryRecord = Class.create();
ValidateOSSLibraryRecord.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isRecordExistInOSSLibrary: function() {
gs.log('insertRecordOSSLibrary : npm : ');
var retVal = 'false';
var packageRegistry = this.getParameter('sysparm_packageRegistry');
var gr = new GlideRecord('u_oss_library');
if (packageRegistry == 'npm' || packageRegistry == 'nuget') {
var packageName = this.getParameter('sysparm_packageName');
var packVersion = this.getParameter('sysparm_packageVersion');
gs.info('Package Name : '+packageName);
gs.info('Package Version : '+packVersion);
//var gr = new GlideRecord('u_oss_library');
gr.addQuery('u_library_name', packageName);
//gr.addQuery('u_packagetype', packageRegistry);
gr.addQuery('u_version', packVersion);
gr.query();
if (gr.next()) {
gs.info('NPM/nuget Package Name is already exist');
retVal = 'true';
}
return retVal;
},
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda