- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 10:05 AM
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:
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);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 10:32 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 10:32 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 10:36 AM
This worked! Thank you so much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 10:55 AM