Need to fix this script to create Custom Action in Flow Designer

yjeon92
Tera Contributor

Hello, 

 

I need to adjust this script to work in the custom action.  I'm having trouble trying to adjust it.  It also has to be because I have difficulty understanding custom actions and how they work.

 

Please help adjust this script and if possible the custom action input and output.

 

var empID = '';
var je = new GlideRecord('incident');
je.addQuery('sys_id', '148c06499790b110df5db8a3f153af64');
je.query();
if(je.next()) {
var comm = je.comments.getJournalEntry(1).toString();
var notes = comm.split("\n");
for(var i=0;i<notes.length;i++){
empID = notes[5];
}
gs.info(empID);
}

 

thank you!

4 REPLIES 4

Rahul Talreja
Mega Sage
Mega Sage

Hi @yjeon92 ,

What are you trying to achieve?

Can you please share your desired output 

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

Elijah Aromola
Mega Sage

Custom script actions have inputs to the action itself (from the flow), and then can have inputs at each step. If you need to pass inputs to your script, you must have inputs on the action itself and the script step within the action. 

 

Once you create the inputs and pass the input pill from the action to the step, you can reference them inside your script via inputs.input_name. Similarly you can create outputs by specifying step outputs AND action outputs. You can reference outputs in your script via outputs.output_name.

 

Without screenshots of how your action is setup unfortunately no one can provide a script that will work. It requires setup done through the flow designer UI.

yjeon92
Tera Contributor

My goal is to parse through additional comments to grab the employee id.  Incidents are created by our answering service team and I would like to update my incident record by the employee id in the comment.

You have to configure the inputs to pass in the incident record. If your script works with a static sys_id then you only need to modify it to work with a dynamic action input.