How to add MRVS to sc_task that i created in script on wf?

Omer Revach
Giga Contributor

Hello !

I have variables set of Multi Row type on catalog item and i need to show this mrvs on tasks that i created on wf with run script .

how can i do that ?

this is the script that creates the tasks :

var equipment_req;

var mrvs = JSON.parse(current.variable_pool.details.toString());

for (var x in mrvs) {

    equipment_req = mrvs[x].equipment_req;

    gs.log("equipment_req task_management " + equipment_req);

    var gr = new GlideRecord('u_equipment_types');

    gr.addQuery('sys_id', equipment_req);

    gr.addEncodedQuery('u_task_management!=NULL');

    gr.query();

    while (gr.next()) {

        var tsk = new GlideRecord("sc_task");

        tsk.initialize();

        tsk.request_item = current.sys_id;

        tsk.assignment_group = gr.u_task_management;

        tsk.short_description = "משימת טיוב";

        tsk.state = 1;

        current.stage = "משימת טיוב";

        current.state = 2;

        tsk.insert();

    }

}

image005.pngimage004.pngimage002.pngimage001.png

 

 

 

 

 

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Omer Revach 

why not use Catalog Task Activity in workflow and then add it

Did you not add that MRVS variable set from available to selected in the activity?

You can follow below article to achieve the same:
Multi row variable set (MRVS) not visible in catalog task

Multi-row variable set on Catalog Task [sc_task] 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

because i need one more tasks on one step

look the script ...for example if i have 2 row on mrvs i had two task for first care factor .

so catalog task activity this is not the solution for me...