Adding Custom Field to a notification

Ajith A Pillai
Tera Contributor

Hi All,

 

I have created a email notification in alm_hardware table and I wanted to add a custom field (u_hostname) from cmdb_ci_computer table to that notification. How can we add this?

 

If anyone implemented this, please help me with steps.

 

Thanks in advance!!

Ajith Pillai

 

1 ACCEPTED SOLUTION

Runjay Patel
Giga Sage

Hi @Ajith A Pillai ,

 

You can achieve using email script. use below code in your email script.

var hostname= '';
    var gr = new GlideRecord('cmdb_ci_computer');
    gr.addQuery('asset', current.sys_id);
    gr.query();
    if (gr.next())
        hostname= gr.u_hostname;

    template.print('Host Name: ' + hostname);

 

I have tested this, it will work.

RunjayPatel_0-1731514344379.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

View solution in original post

1 REPLY 1

Runjay Patel
Giga Sage

Hi @Ajith A Pillai ,

 

You can achieve using email script. use below code in your email script.

var hostname= '';
    var gr = new GlideRecord('cmdb_ci_computer');
    gr.addQuery('asset', current.sys_id);
    gr.query();
    if (gr.next())
        hostname= gr.u_hostname;

    template.print('Host Name: ' + hostname);

 

I have tested this, it will work.

RunjayPatel_0-1731514344379.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------