How to add variable set in ''sc_task" page through run script

Krithika R
Tera Contributor

Hi All,
I using the script to add variables and variable task in sc_task page but only variale are visible. Variable set is not visibleon sc_task page.

 Can anyone help me on this ? 

 

  var gr = new GlideRecord('sc_item_option_mtom');
        gr.addQuery('request_item', current.sys_id);
        gr.query();
        while (gr.next()) {
            var getVar = new GlideRecord('item_option_new');
            //getVar.addQuery('cat_item=' + current.cat_item);
            getVar.addEncodedQuery('cat_item=159d51eddb6f21108f50e6650596190b^name!=required_number_of_tasks^ORname=NULL');
            getVar.query();

            //For each variable, create an associated record in sc_item_variables_task
            while (getVar.next()) {
                setVar = new GlideRecord('sc_item_variables_task');
                setVar.initialize();
                setVar.task = task_sys_id;
                setVar.variable = getVar.getValue('sys_id');
                setVar.update();
            }
        }

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Krithika R 

try this

https://snprotips.com/useful-scripts#12 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Krithika R 

try this

https://snprotips.com/useful-scripts#12 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader