How can I query sys_email table in Scripts - Background
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2015 06:36 AM
Hi,
I need to extract some information from sys_email table while I am doing the production issue investigation, but when I run below scripts in the "scripts - background" tool, there's no data list out.
gs.sql("select distinct recipients from sys_email where sys_created_on= '2015-08-22' and subject like 'BCM Governance Declined%'");
Thanks in advance for your help!
Irene
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2015 07:03 AM
Hi Irene, try the following:
var email = new GlideRecord('sys_email');
email.addEncodedQuery('subjectLIKEBCM Governance Declined');
email.query();
while(email.next()){
gs.print(email.recipients);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2015 07:17 AM
Hi Berny,
The script run completed without data print out on the screen. The output
shows as below:
12 Script completed: script
Is there other option or configuration item need to turn on ?
Thanks,
Irene
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2015 07:22 AM
Hi Irene,
Does the email truly contains the string: BCM Governance Declined?
If you're not getting any records it's then because the subject may be different.
One additional note, make sure that your elevated privileges session has not expired. Not getting any records could also be a result of having an expired elevated priv session.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2015 08:14 AM
Hi Berny,
The list can be extract from the UI by the export function, The
scrip-backgound can't output any data on the sys_email table, however, I
have tried different query. Is there any properties that configure this
table not be query?
Thanks,
Irene
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2015 08:17 AM
Hi Irene, not at all. You should be able to query sys_email from any script using a GlideRecord
Try the following and please let me know how it goes.
var email = new GlideRecord('sys_email');
email.query();
while(email.next()){
gs.print(email.sys_id);
}