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

We want to do it from Flow Designer because there are other actions that will need to be performed, but in the flow designer the only option it gives for a selection is Service Catalog

find_real_file.png

@Ankur Bawiskar - No name and email does not exist. I am trying to avoid creating a workflow through workflow editor. It has been recommended to use Flow Designer.

@mballinger 

That was my 1st question and I informed about that.

Flow designer doesn't work on record producer.

So if you cannot do that using flow then use after insert and the logic I shared.

Just use correct field names from custom table and correct mrvs variable set name and the variables within MRVS

Regards
Ankur

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

I have created a flag on my RP and our custom app. The flag is called "Created from RP". When the RP is submitted, I map the fields to the record. I now have a way of triggering a Flow. 

Now, from the flow designer, how can I create new records from MRVS?

Thanks!

@mballinger 

If you are unable to get the MRVS variable value in your flow using the Get Catalog Variables you cannot proceed with the Flow approach.

So the final method would be to use after insert BR and the sample script I shared.

Regards
Ankur

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