My custom action script is not working in my flow design

yjeon92
Tera Contributor

yjeon92_1-1693933365329.png

So my custom script should parse through the most recent comment to find the employee number but when I try to look up the record, the runtime value has a decimal. 

 

Do you happen to know what is going on with this?  

 

In my custom action, the employee id output is a string and comes out correctly:

yjeon92_2-1693933503375.png

this is my script:

(function execute(inputs, outputs) {
var match ;
var gr = new GlideRecord('incident');
gr.addEncodedQuery('number='+inputs.incident_number+'^ORsys_id='+inputs.incident_number);
gr.query();
if (gr.next()) {
var comments = gr.comments.getJournalEntry(1);
var regex = /\b\d{5}\b/;
match = comments.match(regex);
}

if (match) {
outputs.employee_id = Number(match[0]);
}


})(inputs, outputs);

1 ACCEPTED SOLUTION

Tushar
Kilo Sage
Kilo Sage

Hi @yjeon92 

 

Please try below code - 

 

(function execute(inputs, outputs) {
  var match;
  var gr = new GlideRecord('incident');
  gr.addEncodedQuery('number=' + inputs.incident_number + '^ORsys_id=' + inputs.incident_number);
  gr.query();
  
  if (gr.next()) {
    var comments = gr.comments.getJournalEntry(1);
    var regex = /\b\d{5}\b/;
    match = comments.match(regex);
  }

  if (match) {
    outputs.employee_id = match[0]; // Keep it as a string
  }
})(inputs, outputs);

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar

View solution in original post

3 REPLIES 3

Tushar
Kilo Sage
Kilo Sage

Hi @yjeon92 

 

Please try below code - 

 

(function execute(inputs, outputs) {
  var match;
  var gr = new GlideRecord('incident');
  gr.addEncodedQuery('number=' + inputs.incident_number + '^ORsys_id=' + inputs.incident_number);
  gr.query();
  
  if (gr.next()) {
    var comments = gr.comments.getJournalEntry(1);
    var regex = /\b\d{5}\b/;
    match = comments.match(regex);
  }

  if (match) {
    outputs.employee_id = match[0]; // Keep it as a string
  }
})(inputs, outputs);

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar

@Tushar  

This worked!  Thank you so much

Tushar
Kilo Sage
Kilo Sage

Happy to help @yjeon92, can you please mark it as helpful.

 

Thanks.