Database view between alm_hardware and sn_hamp_m2m_audit_asset table

SanketKumaS
Tera Contributor

Could anyone please help on how to create a database view between alm_hardware and sn_hamp_m2m_audit_asset table? I want the audit status from M2M table to be displayed on the report with the corresponding audit number field on the alm_hardware table.

2 ACCEPTED SOLUTIONS

pr8172510
Tera Guru

Hey @SanketKumaS,

Navigate to System Definition > Database Views and click New .

  1.  Add the Main Table (alm_hardware)

In the View Tables related list, add your first table:

  • Table: alm_hardware

  • Order: 100

  • Variable Prefix: hw

  2. Add the Second Table (sn_hamp_m2m_audit_asset) with a Join

Now add the M2M table to link it:

  • Table: sn_hamp_m2m_audit_asset

  • Order: 200

  • Variable Prefix: audit

  • Where clause: hw.sys_id = audit.asset

 

    3. Add Your Fields

   Next, go to the View Fields related list. Click New and select the specific fields you want to bring into your report:

  • From alm_hardware: Pick asset_tag, serial_number, model, etc.

  • From sn_hamp_m2m_audit_asset: Add audit_status and the reference to the audit record itself. That audit field will link directly back to the audit header record you need .

      4.Save & Test

Save the Database View, then click the Try It . 

pr8172510_0-1779106158369.png

 

pr8172510_1-1779106185231.png

 

 

 

View solution in original post

Tanushree Maiti
Tera Patron

Hi @SanketKumaS 

 

Try with this:

 

Table OrderVariable PrefixWhere Clause
Hardware (alm_hardware)100hw 
Asset Audit M2M (sn_hamp_m2m_audit_asset)200m2mm2m_asset = hw_sys_id
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

View solution in original post

4 REPLIES 4

pr8172510
Tera Guru

Hey @SanketKumaS,

Navigate to System Definition > Database Views and click New .

  1.  Add the Main Table (alm_hardware)

In the View Tables related list, add your first table:

  • Table: alm_hardware

  • Order: 100

  • Variable Prefix: hw

  2. Add the Second Table (sn_hamp_m2m_audit_asset) with a Join

Now add the M2M table to link it:

  • Table: sn_hamp_m2m_audit_asset

  • Order: 200

  • Variable Prefix: audit

  • Where clause: hw.sys_id = audit.asset

 

    3. Add Your Fields

   Next, go to the View Fields related list. Click New and select the specific fields you want to bring into your report:

  • From alm_hardware: Pick asset_tag, serial_number, model, etc.

  • From sn_hamp_m2m_audit_asset: Add audit_status and the reference to the audit record itself. That audit field will link directly back to the audit header record you need .

      4.Save & Test

Save the Database View, then click the Try It . 

pr8172510_0-1779106158369.png

 

pr8172510_1-1779106185231.png

 

 

 

Thank you. It worked.

Tanushree Maiti
Tera Patron

Hi @SanketKumaS 

 

Try with this:

 

Table OrderVariable PrefixWhere Clause
Hardware (alm_hardware)100hw 
Asset Audit M2M (sn_hamp_m2m_audit_asset)200m2mm2m_asset = hw_sys_id
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Thank you.This also worked.