Pass object to sub-flow

perosterber
Tera Contributor

Hello,

 

I have a script action which parses MRVS objects and return a html table string. This works when needed for flows. 

I wanted to use this also in a email script, so I created a sub-flow which will call the flow script action. (as I cannot call the flow script action directly from a script to my knowledge )

 

The problem is that the sub-flow seem not be able to receive the current.variables.<MRVS>. If I gs.log(current.variables.<MRVS>) it will print the information. But if I look in the flow context of the receiving sub-flow the values are null. What am I missing?

5 REPLIES 5

pr8172510
Tera Expert

Hi,

This is a common issue when passing MRVS data into a subflow.

What’s happening

current.variables.<MRVS> is not a plain object — it’s a GlideElement / GlideRecord-like structure, so while gs.log() can print it, Flow Designer cannot serialize it properly when passing it as an input.

That’s why:

  • You see values in logs
  • But in the subflow context → it shows as null

How to fix it

You need to convert the MRVS into a true JSON object or array before passing it to the subflow.

Recommended approach

var mrvs = current.variables.databasflytt; // MRVS name

var result = [];

for (var i = 0; i < mrvs.getRowCount(); i++) {
var row = mrvs.getRow(i);
var obj = {};

obj.field1 = row.field1.toString();
obj.field2 = row.field2.toString();
// add all required fields

result.push(obj);
}

inputs['mrvs_object'] = result; // Array.Object

Important points

  • Do NOT pass current.variables.<MRVS> directly
  • Always convert to:
    • Array of objects (best option)
    • Or JSON string (JSON.stringify(result))

Subflow input type

Make sure your subflow input is:

  • Array.Object (for structured data)
    or
  • String (if passing JSON string)

Why this works

Flow Designer only accepts serializable data, not platform-specific objects like GlideElements.




Tanushree Maiti
Tera Sage

Hi @perosterber 

 

Subflows don’t automatically inherit current or its variables, especially MRVS (Multi-Row Variable Sets). variables must be explicitly passed as inputs to a subflow.

 

Follow the steps as given in this post : How to access variable set variables in flow designer .

 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Hi,

 

Yes ofc. Thats why I am trying to pass them but nothing is received, please see attached screenshots.

Ankur Bawiskar
Tera Patron

@perosterber 

you have a flow action or script action?

share that screenshot

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