Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to return a Record from a Flow Designer Action Script Step?

Susan Sellmeye1
Tera Expert

Can someone please help?

I have a FD that calls an Action to create 2 new records and apply a Form Template to each record > this works.

But I need to return the Record that was created for Case and the Record that was created for Incident, back to my Flow.

 

Here is my Action Script Step:

 

    var grCase = new GlideRecord('sn_customerservice_case');

    grCase.initialize();

    grCase.applyTemplate('Case Template 1');

    outputs.record = grCase.insert();

 

    var grINC = new GlideRecord('incident');

    grINC.initialize();

    grINC.applyTemplate('INC Template 1);

    outputs.record = grINC.insert();

 

Can someone help me update this code and provide the Output type that is needed?

I need to return type Record to my Flow so I can access its values.

Thank you!

1 ACCEPTED SOLUTION

Susan Sellmeye1
Tera Expert

I figured out the solution. I had to update the Script Step in the Action, use a String Field in both outputs and in the Flow > use a Look Up Record and Update Record.

Here is the full solution:

 

(function execute(inputs, outputs) {
var grIMS = new GlideRecord('interaction');
grIMS.initialize();
grIMS.applyTemplate('Template 1');
grIMS.insert();
outputs.record = grIMS;
outputs.record1 = grIMS.getValue('number');

 

var grCase = new GlideRecord('sn_customerservice_case');
grCase.initialize();
grCase.applyTemplate('Template 2');
grCase.insert();
outputs.record = grCase;
outputs.record2 = grCase.getValue('number');

var grINC = new GlideRecord('incident');
grINC.initialize();
grINC.applyTemplate('Template 3');
grINC.insert();
outputs.record = grINC;
outputs.record3 = grINC.getValue('number');;

})(inputs, outputs);

 

Script Step Outputs:

SusanSellmeye1_0-1672249054985.png

 

Action Output Outputs:

SusanSellmeye1_1-1672249113288.pngSusanSellmeye1_2-1672249139290.png

 

 

In the Flow:

Call the Action

Look Up Record 

Update Record

(for all 3 records types)

View solution in original post

7 REPLIES 7

Kashyap G
Tera Expert

 Hi @Susan Sellmeye1 

 

You can create multiple output variables to your flow as shown in the below screenshot.

Screenshot 2022-12-20 at 8.13.01 PM.png

Hope this helps.

*Please mark this as useful based on the impact*

 

Regards,

Kashyap G

Hi @Kashyap G 

With the code I have, type String as an Output does not return the Record... 

Hi @Susan Sellmeye1 ,

 

Try to use the Reference type of Output Variable.

reshmapatil_0-1671550483962.png

 

 

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

 

Hi @reshmapatil 

Type Reference output produces no records.