Create multiple records through Flow Designer from Record Producer

mballinger
Mega Guru

Hello,

I have a record producer with multiple Multi Row Variable Sets. I need to create a flow, when a record is created from the Flow, it needs to grab all the line items from each MRVS and create a new record.

How can I do this?

Thanks!

1 ACCEPTED SOLUTION

@mballinger 

You can also use after insert BR on your record producer target table

Sample Script below

I assume your MRVS has name and email variable

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

	var value = current.variables.variableName;
	if(value){
		var parser = JSON.parse(value);

		for(var i=0;i<parser.length;i++){
			var gr = new GlideRecord("tablename");
			gr.initialize();
			gr.u_name = parser[i].name;
			gr.u_email = parser[i].email;
			gr.insert();
		}
	}

})(current, previous);

Regards
Ankur

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

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I believe Flow won't trigger for Record Producer.

Are you able to trigger it against the record submitted via record producer?

Regards
Ankur

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

Thanks for your response @Ankur Bawiskar. I may have to add another variable to differentiate the record. Once I do that, how would I loop through each of the MRVS and create records? There might also be multiple line items for each MRVS so I would need to account for those as well.

Thanks!

First question are you able to configure flow on trigger of Record producer?

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

@mballinger 

You can also use after insert BR on your record producer target table

Sample Script below

I assume your MRVS has name and email variable

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

	var value = current.variables.variableName;
	if(value){
		var parser = JSON.parse(value);

		for(var i=0;i<parser.length;i++){
			var gr = new GlideRecord("tablename");
			gr.initialize();
			gr.u_name = parser[i].name;
			gr.u_email = parser[i].email;
			gr.insert();
		}
	}

})(current, previous);

Regards
Ankur

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