Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to fetch the value of target field in sys_email(email log) and populate the value in another table ?

surya76
Tera Contributor

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 ?

find_real_file.png

find_real_file.png

thanks

 

3 REPLIES 3

Allen Andreas
Tera Patron

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:

find_real_file.png

var gr = new GlideRecord('sys_email');
gr.get('sys_id_of_that_same_record');
gs.info("Target is: " + gr.instance.getDisplayValue());

find_real_file.png

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

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!

n21lv1
Tera Contributor

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