Restrict submission of the catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2025 05:24 PM - edited ‎02-05-2025 06:31 PM
Please help me on how to write the script to validate the below information.
I have a catalog item with the Application field(reference field) referring to the Business Application table,
If the application is selected, should validate that the following information is available in the application
Name of the application
Business Owner
Technology Owner
Technology Domain (field from parent table "Business application group" named domain(ref field))
If any of these fields are null, the user should be directed to contact archi@gmail.com to have the information updated with an appropriate amount of time for the updates to be visible in the form. The form submission should be disabled.
Only if the app is selected and all fields are available in App should the user be allowed to complete and submit the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2025 08:43 PM
you can do this
1) create onChange catalog client script and use GlideAjax and check if any 1 field from your list is empty
2) if yes then show error message to contact that email and make that variable mandatory so that users can't submit the catalog item
3) if all fields are populated then clear the error message
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
‎02-05-2025 08:53 PM
something like this, please enhance as per your requirement
onChange
function onChange(control, oldValue, newValue, isLoading) {
if (!isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg('application');
var application = g_form.getValue('application');
if (application) {
var ga = new GlideAjax('ValidateApplicationFields');
ga.addParam('sysparm_name', 'validateDetail');
ga.addParam('sysparm_app', application);
ga.getXMLAnswer(function(response) {
if (response != 'valid') {
alert('Please contact archi@gmail.com to update the application information.');
g_form.showFieldMsg('application', 'Form submission is disabled until the application information is updated.', 'error');
g_form.clearValue('application');
}
});
}
}
Client callable script include
var ValidateApplicationFields = Class.create();
ValidateApplicationFields.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateDetail: function() {
var sys_id = this.getParameter('sysparm_app');
var appGR = new GlideRecord('business_application');
if (appGR.get(sys_id)) {
var name = appGR.getValue('name');
var businessOwner = appGR.getValue('business_owner');
var technologyOwner = appGR.getValue('technology_owner');
var domain = appGR.getValue('domain');
if (name && businessOwner && technologyOwner && domain) {
return 'valid';
}
}
return 'invalid';
},
type: 'ValidateApplicationFields'
});
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
‎02-05-2025 10:21 PM
Here, in this we need to get the domain from the parent table for business application
ie u_cmdb_ci_business_application_group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2025 01:20 AM
@Ankur Bawiskar please help