- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 12:32 AM
Hi,
I have a requirement to check if I have received an email for the current incident. For this I am using glide record to query the sys_email table with current incident number to check if the email is there or not. I am searching the incident number in the target field of sys email but it seems query is not working. Could someone please help in resolving this?
Below is the code:
var id = fd_data.trigger.current.case;
gs.info("id is" + id);
if (id) {
var emailCheck = new GlideRecord('sys_email');
emailCheck.addQuery('instance', id);
emailCheck.query();
if (emailCheck.next()) {
return true;
} else {
return false;
}
Note: This script is used in flow to set the flow variable value.
Please suggest, how to fix it?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 04:35 AM
Hi,
I was able to fix the issue by using sys id of the record as the query. Below code worked for me:
var id = fd_data.trigger.current.sys_id;
gs.info("id is" + id);
if (id) {
var emailCheck = new GlideRecord('sys_email');
emailCheck.addQuery('instance', id);
emailCheck.query();
if (emailCheck.next()) {
return true;
} else {
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 12:53 AM
Hi @SK41 ,
Can you please refer below code
var id = fd_data.trigger.current.case;
var idStr = id.toString();
if (id) {
var emailCheck = new GlideRecord('sys_email');
emailCheck.addQuery('instance', idStr);
emailCheck.query();
if (emailCheck.next()) {
gs.log('Inside IF');
} else {
gs.log('Inside Else');
}
Please reach me out if you need anything.
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 04:35 AM
Hi,
I was able to fix the issue by using sys id of the record as the query. Below code worked for me:
var id = fd_data.trigger.current.sys_id;
gs.info("id is" + id);
if (id) {
var emailCheck = new GlideRecord('sys_email');
emailCheck.addQuery('instance', id);
emailCheck.query();
if (emailCheck.next()) {
return true;
} else {
return false;
}