- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 04:00 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 05:47 AM
what is field type for u_category_lead in table sn_customerservice_category_leader?
Seems it's a list field holding multiple sysIds and hence it's not working
If yes then script include function needs change so that it pushes the values correctly
var LeaderApproval = Class.create();
LeaderApproval.prototype = {
initialize: function() {},
getCategory: function(category, functions, regionValue) {
var categoryList = [];
var categoryValue = '';
var functionsValue = '';
var grn = new GlideRecord("sn_customerservice_procurement_category");
grn.addQuery("sys_id", category);
grn.addQuery("u_procurement_function", functions);
grn.query();
if (grn.next()) {
categoryValue = grn.u_procurement_category.toString();
functionsValue = grn.u_procurement_function.toString();
}
var arrayUtil = new global.ArrayUtil();
var gr = new GlideRecord('sn_customerservice_category_leader');
gr.addQuery('u_category', categoryValue);
gr.addQuery('u_tower', functionsValue);
gr.addQuery('u_region', regionValue);
gr.query();
while (gr.next()) {
var arr = gr.u_category_lead.toString().split(',');
if (arr.length > 0) {
// if it's array then concat and store in categoryList array
categoryList = arrayUtil.concat(categoryList, arr);
} else {
categoryList.push(gr.u_category_lead.toString());
}
}
categoryList = arrayUtil.unique(categoryList); // get unique
//return "sys_idIN" + categoryList;
return categoryList;
},
type: 'LeaderApproval'
};
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
01-30-2025 05:35 AM
this is BR witter, getting approvals sysids using script include(LeaderApproval) and then creating multiple approvals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 05:47 AM
what is field type for u_category_lead in table sn_customerservice_category_leader?
Seems it's a list field holding multiple sysIds and hence it's not working
If yes then script include function needs change so that it pushes the values correctly
var LeaderApproval = Class.create();
LeaderApproval.prototype = {
initialize: function() {},
getCategory: function(category, functions, regionValue) {
var categoryList = [];
var categoryValue = '';
var functionsValue = '';
var grn = new GlideRecord("sn_customerservice_procurement_category");
grn.addQuery("sys_id", category);
grn.addQuery("u_procurement_function", functions);
grn.query();
if (grn.next()) {
categoryValue = grn.u_procurement_category.toString();
functionsValue = grn.u_procurement_function.toString();
}
var arrayUtil = new global.ArrayUtil();
var gr = new GlideRecord('sn_customerservice_category_leader');
gr.addQuery('u_category', categoryValue);
gr.addQuery('u_tower', functionsValue);
gr.addQuery('u_region', regionValue);
gr.query();
while (gr.next()) {
var arr = gr.u_category_lead.toString().split(',');
if (arr.length > 0) {
// if it's array then concat and store in categoryList array
categoryList = arrayUtil.concat(categoryList, arr);
} else {
categoryList.push(gr.u_category_lead.toString());
}
}
categoryList = arrayUtil.unique(categoryList); // get unique
//return "sys_idIN" + categoryList;
return categoryList;
},
type: 'LeaderApproval'
};
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
01-30-2025 05:50 AM
u_category_lead is list collector field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 05:57 AM
solution shared above should work then
My guess was right so please use the script above
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
01-30-2025 06:17 AM
yes, arrayUtil works