The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Display catalog variables on table extended on task

fereshtehshafag
Tera Contributor

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.

 

0 REPLIES 0