how to fetch the value of target field in sys_email(email log) and populate the value in another table ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 05:34 AM
hi iam trying to fetch the value of Target field(Backend name-instance) in sys_email(email log table) table but its pointing some whehere else its not fetchung the display value
how to fetch the value of target field in sys_email(email log) and populate the value in another table ?
thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 06:43 AM
Hi,
Can you give a bit more information as to what you're trying to do?
Your query is looping through all sys_email records that don't have a recipient on it and then iterating through your script.
I've done the same and it does get the display value:
var gr = new GlideRecord('sys_email');
gr.get('sys_id_of_that_same_record');
gs.info("Target is: " + gr.instance.getDisplayValue());
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 06:48 AM
You've also posted a duplicate post here: https://community.servicenow.com/community?id=community_question&sys_id=b83cced0db618510a53882630596... that I've tried to have redirected back to this one since there's already a reply here.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 01:04 PM
instance is a Document ID field, so its display value is shown in the <Table label>: <Display value> format. If you want to get a proper display value, fetch the value of table_name and use something like
var targetGr = new GlideRecord(emaill.getValue('target_table'));
if (targetGr.get(emaill.getValue('instance'))) {
gg = targetGr.getDisplayValue();
}
Pro-tip: if you only need specific values from a large table, use GlideAggregate instead.