If the Requested for user Location & Country is not India, do not allow to submit the catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 09:03 AM
If the Requested for user Location & Country is not India, do not allow to submit the catalog item and show error message and if the Location & Country is India then catalog item is submitted.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 09:16 AM
Instead of validating on submit, its better to filter the Requested for variable via Reference Qualifier condition.
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 09:50 AM
Hello, Narsing1
I don't have to use reference qualifier,
I have to complete this task using catalog client script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 08:06 PM
Do like this
Script Include (Client Callable): userUtils
var userUtils = Class.create();
userUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isIndia: function() {
var uid = this.getParameter("sysparm_uid");
var gruser = new GlideRecord("sys_user");
gruser.get(uid);
if (gruser.location.country == "India")
return "yes";
else
return "no";
},
type: 'userUtils'
});
Onsubmit Client Script
function onSubmit() {
//Type appropriate comment here, and begin script below
var scratchpad = g_scratchpad || NOW;
if (scratchpad.isFormValid) {
return true;
}
var actionName = g_form.getActionName();
var ga = new GlideAjax("userUtils");
ga.addParam('sysparm_name', 'isIndia');
ga.addParam("sysparm_uid", g_form.getValue("requested_for"));
ga.getXML(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == "no") {
scratchpad.isFormValid = false;
g_form.addErrorMessage("Invalid Requested for");
} else {
scratchpad.isFormValid = true;
g_form.submit(actionName);
}
});
return false;
}
please mark correct and/or helpful.
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 09:22 AM
Hi @Omkarbh97,
My advice here would actually be to control this via User Criteria. This means the Catalog Item should not be visible for those user profiles that are not localized in India - why allow someone to fill out a request if they can't submit it.
To use 'User Criteria' - see the following link where the example mentions location data as a filtering criterion
To help others, please mark correct and/or helpful.
Thanks,
Robbie
User Criteria with Catalog Items:
If you do however want to allow a user to see and enter the details into a catalog item but prevent them from submitting, see here: https://www.servicenow.com/community/itsm-forum/how-to-restrict-catalog-item-for-user-country/m-p/71...