Create each task for every entry on Multi Row Variable Set (MRVS)

Shruti Navalgu1
Kilo Contributor

I am trying to create each task for every entry on the multi-row variable set. I am using flow designer to achieve but it doesn't work, please let me know if there is any other way to get through this

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hello Shruti,

You can write after Br on sc_req_item and can create catalog tasks. you can try like this

After insert on sc_req_item

condition: item is <your_cat_item>

Script

var mrvs = current.variables.your_mrvs_name;
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
  //if you wnat to read data from mrvs and assign to task then
  var row = mrvs.getRow(i);
  var sc_task = new GlideRecord("sc_task");
  sc_task.initialize();
  sc_task.short_description = row.your_variable;
  sc_task.insert();
}

Mark the comment as a correct answer and also helpful if it helps to solve the problem.

 

View solution in original post

18 REPLIES 18

So can you share what you tried and didn't work? Because if you follow the exact steps from the article, it works instantly.

Have you also added some debugging? To see quicker until where the scripting is working as expected, and from where it fails?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hello Shruthi,

The log says undefined because we are not using parsed variable anymore. If you check my code and the one that has fixed for you, they both are actually same 🙂 

 

 

Mark Roethof
Tera Patron
Tera Patron

Hi there,

See below article which I wrote a few months back. Does something similar like you are describing:

- 2020-06-01 Creating records from Multi Row Variable Set 

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

Please find the below changes i made to script and tested, the tasks aren't created - 

find_real_file.png

 

Am i doing it right? Can you please check once.

 

Thanks,

Shruti

This looks like a Business Rule, correct? When does it run? Have you also checked if the script actually got triggered?
You might face timing issues here. Better would be to add this to the workflow / flow.

I will try to simulate what you've set up.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn