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

Hi Mark,

Yes it is a BR and the yes the BR is triggered as i could see the logs used in the script, please find the condition -

find_real_file.png

 

find_real_file.png

 

Thanks,

Shruti 

 

Did you see my other comment? With updated script, tested and works.

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

Works instantly here. Only difference is I used field request_item:

(function executeRule(current, previous /*null when async*/) {

	gs.info('>>> DEBUG');
	
	var rowsInt = current.variables.for_bulk_request.getRowCount();

	for(var i = 0; i < rowsInt; i++) {
		var grIncident = new GlideRecord('sc_task');
		grIncident.initialize();
		grIncident.setValue('request_item', current.getUniqueValue());
		grIncident.setValue('short_description', current.variables.for_bulk_request.getRow(i).u_name);
		grIncident.insert();
	}

})(current, previous);

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,

Thanks a ton ton ton (i was struggling last three days using all the ways to get this worked :)), i used the code in workflow, and it works perfectly fine now.

 

I removed the old script and updated with the one you provided me.

 

find_real_file.png

 

It is of great help :). 

 

Thanks,

Shruti