- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 09:00 AM
In Flow Designer - Custom Action, my input is incident_number which refers to Records.
This is my Script Step:
function execute(inputs, outputs) {
var gr = new GlideRecord(inputs.incident);
gr.query();
if (gr.next()) {
var comments = gr.comments.getJournalEntry(1);
var regex = /\b\d{5}\b/;
var match = comments.match(regex);}
if (match) {
outputs.employee_id = match[0];
}
}
(inputs, outputs);
and my output is the employee_id.
My goal is to look up the incident record to parse through the additional comment to find the Employee ID and output the employee_id as an integer. My issue is my output is not working even though the script goes through the testing. Please help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 10:04 AM - edited 08-25-2023 10:06 AM
Hello @yjeon92
Please Copy Paste and try following code .
(function execute(inputs, outputs) {
var match ;
var gr = new GlideRecord('incident');
gr.addEncodedQuery('number='+inputs.incident_number+'^ORsys_id='+inputs.incident_number); // add your filed name which your passing as parameter to query in incident table.
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 = parseInt(match[0])+1;
}
// ... code ...
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 09:36 AM
Hello @yjeon92 ,
Can you please try following code in action
function execute(inputs, outputs) {
var match ;
var gr = new GlideRecord('incident');
gr.addQuery('your_field_name',inputs.incident); // add your filed name which your passing as parameter to query in incident table.
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];
}
}
(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 09:39 AM
I still get the same result as the previous one where the code is running BUT the output doesn't have the employee ID as the outcome based on the comment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 09:44 AM - edited 08-25-2023 09:44 AM
Hi @yjeon92
Can you please share the screen print of flow where you calling this action So it will easy to understand what we're passing in parameter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 09:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 09:53 AM
Hello @yjeon92 your glide record is bit wrong
you need to use add query like this
function execute(inputs, outputs) {
var match ;
var gr = new GlideRecord('incident');
gr.addQuery('number',inputs.incident); // add your filed name which your passing as parameter to query in incident table.
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];
}
}
(inputs, outputs);
Hope this helps
Mark the answer correct if this helps you
Thanks