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

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)

Thank you for this, this was driving me mad. Who knew you had to return a gliderecord as a string. How does that even work. 

SNC Developer
Tera Contributor

Hi Susan, 

 

I am facing the exact same issue except that I am creating a sc_task in the custom action. I am returning the sc_task.number as a string from the custom action, then doing a Lookup Record, I still get the "Record Not Found" error. I have attached screen shots. Any suggestions?

 

Thanks!