Display catalog variables on table extended on task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All
I am looking in existing implementation, they used RITM > Custom task
They didnt used the sc_task under RITM regarding security and sc_task is not extensible, so they extended task table.
The problem is since variables belong to catalog they dont show on custom task table
so what I did I copy the variables into question anwer table however I have issues linking variable sets
var ritm_vars = new GlideRecord("sc_item_option_mtom");
ritm_vars.addQuery("request_item", RITM_id);
ritm_vars.query();
var variablesets = [];
while (ritm_vars.next()) {
var variableSet = new GlideRecord("item_option_new");
if (ritm_vars.sc_item_option && ritm_vars.sc_item_option.item_option_new && ritm_vars.sc_item_option.item_option_new != "" && variableSet.get(ritm_vars.sc_item_option.item_option_new)) {
var newVariableset = variableSet.variable_set.getValue();
//if (!newVariableset || newVariableset == "") {
var gr = new GlideRecord('question_answer');
gr.initialize();
gr.table_name = 'custom_task';
gr.table_sys_id = custom_task_id;
gr.question = ritm_vars.sc_item_option.item_option_new;
gr.value = ritm_vars.sc_item_option.value;
gr.order = ritm_vars.sc_item_option.order;
var sys_id = gr.insert();
//}
if (newVariableset && newVariableset != "" && variablesets.indexOf(newVariableset) < 0) {
variablesets.push(newVariableset)
var gr = new GlideRecord('question_answer');
gr.initialize();
gr.table_name = 'custom_task';
gr.table_sys_id = "custom_task_id";
gr.question = ritm_vars.sc_item_option.item_option_new;
gr.value = ritm_vars.sc_item_option.value;
gr.order = ritm_vars.sc_item_option.order;
var sys_id = gr.insert();
var mrv_GR = new GlideRecord("sc_multi_row_question_answer")
mrv_GR.addQuery("parent_id", "RITM_id");
mrv_GR.addQuery("variable_set", newVariableset)
mrv_GR.query();
while (mrv_GR.next()) {
var gr = new GlideRecord('sc_multi_row_question_answer');
gr.initialize();
gr.parent_id = "custom_task_id";
gr.parent_table_name = "custom_task";
gr.variable_set=mrv_GR.variable_set;
gr.question_answer = sys_id;
gr.item_option_new = mrv_GR.item_option_new;
gr.row_index = mrv_GR.row_index;
gr.value = mrv_GR.getValue("value");
gr.insert();
}
}
}
Variable sets are added in sc_multi_row_question_answer and they linked to the questions, however variable editor renders them as single variable
Any thought would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @fereshtehshafag ,
Its happening because variables in ServiceNow are really tied to the RITM / catalog request side (through sc_item_option and sc_item_option_mtom) and then selectively surfaced to tasks via the sc_item_variables_task table (or via marking them global), so unless you explicitly script the mapping / insertion into sc_item_variables_task (or make them global) your custom task won’t render them....
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/