- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 02:27 AM
hi,
I am trying to get a value of a variable from a catalog item in an email script and i have to get the last four digits of that number and getting the last four digits of it.
I am sending it to my email body and i am printing it there.
When the email is triggered i am not getting the last 4 digit value.
Below are the code:
Email Script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 02:34 AM
If you're unsure about how card_number_s is being populated, add some debug logging to verify the value before performing the slice operation: gs.info('Card Number: ' + cardNum);
and If card_number_s is not a string but a number, you will need to convert it to a string before using .slice(). Numbers do not support the .slice() method.
Here's how the final email script should be:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var cardNum = String(current.variables.card_number_s);
var lastFour = cardNum.slice(-4);
template.print(lastFour);
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 02:29 AM - edited 03-24-2025 02:33 AM
Hi @Abdul ,
Can you please confirm on which table is your notification running? Also what is the type of the variable card_number_s?
Thanks,
Rishi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 02:35 AM
sys_script_email this is the table i created and i cant see anything on the form saying that this has to run on any particular table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 02:34 AM
If you're unsure about how card_number_s is being populated, add some debug logging to verify the value before performing the slice operation: gs.info('Card Number: ' + cardNum);
and If card_number_s is not a string but a number, you will need to convert it to a string before using .slice(). Numbers do not support the .slice() method.
Here's how the final email script should be:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var cardNum = String(current.variables.card_number_s);
var lastFour = cardNum.slice(-4);
template.print(lastFour);
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 02:37 AM
Thank you so much it worked