- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 05:07 AM
There is oob widget "sp-variable-editor". I have cloned it and used it in CSM case page in portal.
suppose, we raise case via record producer with 20 variables filled out of 50 variables.
Problem is that it is showing all 50 variables in variable editor, requirement is to only show which is not empty(filled ones)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 05:46 AM
in that cloned widget update these 2 functions getValuesForProducer() and getValues() present in server side
function getValues(table, sys_id, task_id, opened_by) {
var qs = new GlideappVariablePoolQuestionSet();
if (table == "sc_cart_item")
qs.setCartID(sys_id);
else if (table == "sc_task") {
qs.setRequestID(sys_id);
qs.setTaskID(task_id);
} else {
qs.setRequestID(sys_id);
}
qs.load();
var values = {};
var questions = qs.getFlatQuestions().toArray();
for (var i = 0; i < questions.length; i++) {
var q = questions[i];
if (q.getValue()) {
var o = {
value: q.getValue(),
displayValue: q.getDisplayValue(),
type: q.getType()
};
//handling List Collector (21) and Masked (25) variables.
if (o.type == 21)
o.display_value_list = q.getDisplayValues().toArray();
if (o.type == 25 && q.canDecrypt(opened_by, table))
o.decrypted_value = q.decrypt(o.value);
var qKey = q.getName();
if (typeof qKey == 'undefined' || qKey == '')
qKey = "IO:" + q.getId();
values[qKey] = o;
}
}
return values;
}
function getValuesForProducer(table, sys_id, opened_by) {
var qs = new GlideappSequencedQuestionSet();
qs.setTableName(table);
qs.setTableSysID(sys_id);
qs.load();
var values = {};
var questions = qs.getFlatQuestions().toArray();
for (var i = 0; i < questions.length; i++) {
var q = questions[i];
if (q.getValue()) {
var o = {
value: q.getValue(),
displayValue: q.getDisplayValue(),
type: q.getType()
};
//handling List Collector (21) and Masked (25) variables.
if (o.type == 21)
o.display_value_list = q.getDisplayValues().toArray();
if (o.type == 25 && q.canDecrypt(opened_by, table))
o.decrypted_value = q.decrypt(o.value);
var qKey = q.getName();
if (typeof qKey == 'undefined' || qKey == '')
qKey = "IO:" + q.getId();
values[qKey] = o;
}
}
return values;
}
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-09-2025 05:16 AM
Hi,
Please try the following solution. I haven't tried the script, but I believe this should work. Create an onload catalog client script in record producer and select the checkbox says Applies on target record. And add type as Mobile/Service Portal. Once added add the following script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 05:46 AM
in that cloned widget update these 2 functions getValuesForProducer() and getValues() present in server side
function getValues(table, sys_id, task_id, opened_by) {
var qs = new GlideappVariablePoolQuestionSet();
if (table == "sc_cart_item")
qs.setCartID(sys_id);
else if (table == "sc_task") {
qs.setRequestID(sys_id);
qs.setTaskID(task_id);
} else {
qs.setRequestID(sys_id);
}
qs.load();
var values = {};
var questions = qs.getFlatQuestions().toArray();
for (var i = 0; i < questions.length; i++) {
var q = questions[i];
if (q.getValue()) {
var o = {
value: q.getValue(),
displayValue: q.getDisplayValue(),
type: q.getType()
};
//handling List Collector (21) and Masked (25) variables.
if (o.type == 21)
o.display_value_list = q.getDisplayValues().toArray();
if (o.type == 25 && q.canDecrypt(opened_by, table))
o.decrypted_value = q.decrypt(o.value);
var qKey = q.getName();
if (typeof qKey == 'undefined' || qKey == '')
qKey = "IO:" + q.getId();
values[qKey] = o;
}
}
return values;
}
function getValuesForProducer(table, sys_id, opened_by) {
var qs = new GlideappSequencedQuestionSet();
qs.setTableName(table);
qs.setTableSysID(sys_id);
qs.load();
var values = {};
var questions = qs.getFlatQuestions().toArray();
for (var i = 0; i < questions.length; i++) {
var q = questions[i];
if (q.getValue()) {
var o = {
value: q.getValue(),
displayValue: q.getDisplayValue(),
type: q.getType()
};
//handling List Collector (21) and Masked (25) variables.
if (o.type == 21)
o.display_value_list = q.getDisplayValues().toArray();
if (o.type == 25 && q.canDecrypt(opened_by, table))
o.decrypted_value = q.decrypt(o.value);
var qKey = q.getName();
if (typeof qKey == 'undefined' || qKey == '')
qKey = "IO:" + q.getId();
values[qKey] = o;
}
}
return values;
}
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-09-2025 09:50 PM
this widget is visible for all CSM cases. I want to show only for specific case where "category=invoice" and "status=12"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2025 04:48 AM
you will have to enhance the code from your side.
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