Where is this Apply Template button defined?

thomaskennedy
Kilo Sage

Where is this Apply Template button defined? It appears on the email template card under Email template contextual sidebar.

 

thomaskennedy_0-1791904580394.png

The reason I ask is that, for a particular template having two To email addresses, when I apply it to my email, the addresses appear to be duplicated. That is, one data pill appears twice, while the other does not appear.

thomaskennedy_1-1791904995772.png

thomaskennedy_2-1791905043687.png

But if I copy the data pills out to a text editor, the labels are wrong while the underlying addresses are correct.

thomaskennedy_3-1791905088299.png

 

"Insider Threat" <Legal_LitHold@xxxxx.com>

"Insider Threat" <InsiderThreat@xxxxx.com>

 

So the data pills are getting messed up, somehow. This doesn't happen for any other case.

 

So I want to get a look at the code that is running when I click on Apply Template, but the debugger doesn't tell me anything. Where does this button live?

 

1 ACCEPTED SOLUTION

sanjaygupta
Tera Guru

Hi, the Apply Template button isn’t a standalone script you can find in a business rule or UI action. It is part of the email composer component used in Workspace. The component documentation lists “Apply Template” as one of the controls in the mini email composer, and the same action also appears from the Email template icon in the contextual sidebar. That is why the debugger shows nothing, as the logic runs in the UI Builder component and not in server-side script.

To look at how it is wired, you can follow this path.

  • Go to All > UI Builder and open the experience for your workspace (for example, the one for HR Case Management).
  • Open the record page variant you use, such as Case SRP. Duplicate it before changing anything, since it is an out-of-box record.
  • Select the Activity Stream Compose node, and check its email composer configuration and event handlers.
  • Use the browser developer tools Network tab while clicking Apply Template to see which data resource is called.

The template content itself comes from Email Client Template records (sys_email_client_template_list). A community answer notes these are configured per table. So the recipients are defined on that record, which is the best place to check your duplicate pill.

  • Open the Email Client Template and look at the Recipients (To) field.
  • Check that the two addresses are separated by a comma only and don’t carry the same display name in the “Name <email>“ format.
  • Try one address as a plain email address to see whether the pill label then displays correctly.
  • Test with the second address first, to see if the issue follows the address or the position.

Since the underlying addresses are correct when copied, this looks like a display issue with the pill labels and not a delivery problem. I couldn’t find a documented cause for it, so if the steps above don’t resolve it, a support case with a reproducible template would be the safe next step. Test in a sub-production instance before changing production templates.

Hope you found it helpful.

Sources:

View solution in original post

5 REPLIES 5

Vishal Jaswal
Tera Sage

Hello @thomaskennedy 

Ensure the email template recipients are comma delimited (you may or may not have a whitespace post comma) as shown below:

VishalJaswal_2-1791906081252.png

 

VishalJaswal_1-1791906068885.png

 

 

Vishal,

 

They are comma-delimited, no space.

Hi @thomaskennedy 

Then my recommendation would be test it out with following scenarios:

1. Create new email template with same recipients and different recipients in cc / bcc.
2. Update your existing email template with different recipients.

If both of the above test failed, then it is good to be reported as a bug to ServiceNow support via HI Case. 

sanjaygupta
Tera Guru

Hi, the Apply Template button isn’t a standalone script you can find in a business rule or UI action. It is part of the email composer component used in Workspace. The component documentation lists “Apply Template” as one of the controls in the mini email composer, and the same action also appears from the Email template icon in the contextual sidebar. That is why the debugger shows nothing, as the logic runs in the UI Builder component and not in server-side script.

To look at how it is wired, you can follow this path.

  • Go to All > UI Builder and open the experience for your workspace (for example, the one for HR Case Management).
  • Open the record page variant you use, such as Case SRP. Duplicate it before changing anything, since it is an out-of-box record.
  • Select the Activity Stream Compose node, and check its email composer configuration and event handlers.
  • Use the browser developer tools Network tab while clicking Apply Template to see which data resource is called.

The template content itself comes from Email Client Template records (sys_email_client_template_list). A community answer notes these are configured per table. So the recipients are defined on that record, which is the best place to check your duplicate pill.

  • Open the Email Client Template and look at the Recipients (To) field.
  • Check that the two addresses are separated by a comma only and don’t carry the same display name in the “Name <email>“ format.
  • Try one address as a plain email address to see whether the pill label then displays correctly.
  • Test with the second address first, to see if the issue follows the address or the position.

Since the underlying addresses are correct when copied, this looks like a display issue with the pill labels and not a delivery problem. I couldn’t find a documented cause for it, so if the steps above don’t resolve it, a support case with a reproducible template would be the safe next step. Test in a sub-production instance before changing production templates.

Hope you found it helpful.

Sources: