Database view and Document ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2025 01:22 PM
Hello all,
I have been scanning the community for all articles related to Document ID with the goal of obtaining the sys_id from that type of value. And it seems its not that simple. One suggestion in the following post was:
"I don't think you can get sysId directly of the record being referred by Document ID field....
you can try to create database view table and then export and then it might contain sysId"
I am trying that approach. Here is my database view:
So, I am trying to get all email attachments that were discarded. Then obtaining the email referenced in those. And obtaining the task (specifically Ticket) referenced in the email's 'instance' field (which is of Document ID type).
However no record is being returned and I have 101 records that satisfy the conditions. Can anyone see what is wrong here?
Also, this is very similar to the OOTB incident_metric one and that works fine:
Note: The mi_definition field is of type Document ID.
Appreciate any help.
Thanks,
Deb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2025 09:29 AM - edited ‎03-25-2025 09:30 AM
I saw a space in each Where Clause conditions
Remove space in each Where Clause like below
emailatt_action='discarded'
emailatt_email=em_sys_id
em_instance=tkt_sys_id
Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2025 09:45 AM
OK, did that but no change in outcome still 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2025 10:34 PM
if you are using document id field then there is an extra step you need to take i.e. you need to give table as well
Database view - How to correctly join a table using a document_id field
add this in the 3rd where clause
mi_id = inc_sys_id && mi_table = 'incident'
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2025 07:25 AM - edited ‎03-25-2025 07:26 AM
Thanks for your reply. As per your suggestion I added the table name but still no output:
That last where clause condition is:
email_instance = tkt_sys_id && email_target_table = 'ticket'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2025 08:49 AM
Few suggestions
1) make the variable prefix upto 3 chars
2) which table is that ticket ? are you using correct field name from that table
3) are you sure the action field has value Discarded in it?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader