set the current category to a variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2025 04:14 AM
How to set the current category value to a variable which I created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2025 11:28 PM
For suppose If I open a form of a catalog item IPhone which is in the category Mobile. Now I want to populate the value Mobile in the variable which I created for that catalog item IPhone and when it comes to its type - maybe it is any type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2025 10:06 PM
Hi @ramasatyasa , It should work as this field is available on the native UI catalog item table, and the solution I have provided combines script include and client script so this should work. Have you tried the solution I provided??
If my solution helped you in any way, make sure to mark it as accepted or helpful, this will benefit other users as well.
Best Regards,
Saurabh V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2025 11:05 PM
Hi @ramasatyasa , As far as I understand you want to set a particular table's category value to the variable which you might have created in the catalog item.
In that case you will have to use combination of catalog client script and script include:
Catalog client script - onLoad();
function onLoad() {
var ga = new GlideAjax('scriptIncludeName');
ga.addParam('sysparm_name', 'functionName');
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('variableName', response);
}
});
}
Script include -
var scriptIncludeName = Class.create();
GetCategoryValue.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCategory: function() {
var gr = new GlideRecord('your_table_name');
gr.orderByDesc('sys_created_on');
gr.setLimit(1);
gr.query();
if (gr.next()) {
return gr.getValue('category');
}
return '';
}
});
Try this.
If this solution helped you Please Mark this solution as accepted and helpful as it will be helpful for other users as well.
Best Regards.
Saurabh V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2025 11:29 PM
is setValue works for the variable because it is not a field right
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2025 10:06 PM
Hi @ramasatyasa , It should work as this field is available on the native UI catalog item table, and the solution I have provided combines script include and client script so this should work. Have you tried the solution I provided??
If my solution helped you in any way, make sure to mark it as accepted or helpful, this will benefit other users as well.
Best Regards,
Saurabh V.
