Catalog Client Script to make a variable not visible and not mandatory depending on custom column
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 07:44 AM
We are using the Product Lifecycle table to track all of our hardware and software for Enterprise Architecture. I have a catalog item for requesting non-core software installations that asks for product and department. I need to have the department field not visible or mandatory if the product is enterprise-wide. Here is what I have right now.
Thanks,
Erin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:04 PM
Hello @erin-marie
Please confirm if you checked my answer. Kindly mark my answer as helpful and accept solution if it helped you in anyway, so that it can move from unsolved bucket to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0Wyn
LcOwNeE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 05:40 PM
It isn't working, so I am still looking at it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 07:33 PM
Hello @erin-marie
Can you share scripts or snippets where you are stuck ?
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 10:15 AM
GlideRecord is not recommended in Client Script.
You should be using GlideAjax in this case. Below you can find few examples
https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430
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
04-02-2025 10:59 PM
Hi @erin-marie ,
try below
adjust as per your variable names and requirements
create a client callable script include
var getFieldValues = Class.create();
getFieldValues.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getValueOfSingleFieldByID: function() {
var gr = new GlideRecord(this.getParameter('sysparm_table_name'));
var uniqueFieldToGet = this.getParameter('sysparm_uniquefield');
uniqueFieldToGet = uniqueFieldToGet ? uniqueFieldToGet : 'sys_id';
var uid = this.getParameter('sysparm_uniqueid');
if (gr.get(uniqueFieldToGet, uid)) {
return gr.getValue(this.getParameter('sysparm_field'));
}
return null;
},
type: 'getFieldValues'
});
client script
var ga = new GlideAjax('getFieldValues');
ga.addParam('sysparm_name', 'getValueOfSingleFieldByID')
ga.addParam('sysparm_table_name', 'sn_apm_trm_standards_product_lifecycle');
ga.addParam('sysparm_uniqueid', newValue);
ga.addParam('sysparm_uniquefield', 'trm_product');
ga.addParam('sysparm_field', 'u_enterprise_wide');
ga.getXMLAnswer(function(answer) {
if (answer && (answer == 'true' || answer == '1')) {
g_form.setMandatory('sc_sw_noncore_trmdepartment', false);
g_form.setDisplay('sc_sw_noncore_trmdepartment', false);
} else {
g_form.setMandatory('sc_sw_noncore_trmdepartment', tue);
}
});
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya