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 create Database View to join cert_element and incident table?

Dennis25
Tera Contributor

Hello,

I have set up Data Certification for certain fields from Incident table.

As you can see below, by reporting only on cert_element table, I am not able to add in more fields from incident table (i.e: incident.priority, incident.assignment group, incident.service_offering).

So I thought of creating a Database View to join cert_element and incident table to get the fields I need from incident table. 

find_real_file.png

 

Which fields do I use to join cert_element table and incident table using Database View?

I have tried as below.

find_real_file.png

But getting error that ce.id is unknown.

find_real_file.png

I have checked in the cert_element table that it should be there.

ce.id is actually as below:

find_real_file.png

 

Any ideas here are greatly appreciated.

Thanks in advance.

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hey Dennis,

Found one related article on HI:

Description

When creating a database view it is sometimes necessary to join tables via a Document ID type field.

 

Like Reference fields, Document ID fields allow the record to reference another record. However, Document ID fields allow you to reference a record on any table, not just a pre-defined one like Reference fields.

 

This means that the data is stored in 2 fields: Table Name & Document (sys_id)

 

Incorrectly joining tables by only referencing the Document field can lead to unexpected outcomes like only returning partial results or, a mismatch between the row count and the results returned.

 

Ref link:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0952022

Best Regards
Aman Kumar

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Did you add id field as view field for that cert_element table?

Are you sure that field is holding incident sysId?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

check this out

Database view - How to correctly join a table using a document_id field

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Dennis 

Did you mistakenly marked other response as correct?

The link I shared already provided the same solution.

Please mark appropriate response as correct based on timely response.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Aman Kumar S
Kilo Patron

Hey Dennis,

Found one related article on HI:

Description

When creating a database view it is sometimes necessary to join tables via a Document ID type field.

 

Like Reference fields, Document ID fields allow the record to reference another record. However, Document ID fields allow you to reference a record on any table, not just a pre-defined one like Reference fields.

 

This means that the data is stored in 2 fields: Table Name & Document (sys_id)

 

Incorrectly joining tables by only referencing the Document field can lead to unexpected outcomes like only returning partial results or, a mismatch between the row count and the results returned.

 

Ref link:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0952022

Best Regards
Aman Kumar