Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..

cancel
Showing results for 
Search instead for 
Did you mean: 

Button to Open Specific Email Template

cameronk
Contributor II

Hello,

I am trying to create a custom object button which will open a specific email template.

At first I was trying to do something like:

document.querySelectorAll('iframe')[0].contentWindow.document.querySelector('a[title="<template name>"]').click()

But this does not work because the templates open up in a new iframe outside of the reach of the button.

I am suspecting there may be some solution similar to this where I can populate information about the template into an existing function, but I am not sure if that function is even available from the button's environment: https://www.archerirm.community/t5/archer-custom-objects-forum/custom-object-to-select-specific-mail-merge-object/td-p/662876

Currently I just have a button which performs a master_btnEmail.click() but that means the user still needs to go through and find the appropriate template from the list.

Any suggestions would be much appreciated. Thank you.

 

 

4 REPLIES 4

DavidPetty
Archer Employee
Archer Employee

@cameronk if you inspect the element of one of the on-demand notifications you can see what actually being called and you should be able to use that in your custom object.

For example, here's one of the on-demand notifications from the Findings application.

<a title="FIND: Assignee Notification for Submission" onclick="javascript&colon;GetEmailClientWindow('EmailClient.aspx?notificationId=386&amp;contentId=274127&amp;subject=FND-2','EmailClient', document.body.offsetHeight - 40, document.body.offsetWidth - 40, 'On Demand Email Dialog' ); return false;" href="javascript&colon;void(0);" target="EmailClient">FIND: Assignee Notification for Submission</a>

 

 Advisory Consultant

Thanks very much for the response!

I am still hitting an issue, unfortunately. When I try to use the button included above I get an error: "An unexpected error has occurred in the system. Please try your request again. If problems persist, please contact your system administrator. " I get this error when swapping out the notificationID, ContentID, and subject to the ones I see when I inspect the desired template, or if I leave it the same. I suspect this button is having an issue where this function isn't defined yet.

I get an error saying the function GetEmailClientWindow is not defined if I try entering something like "GetEmailClientWindow('EmailClient.aspx?notificationId=843&contentId=374585&subject=374585','EmailClient', document.body.offsetHeight - 40, document.body.offsetWidth - 40, 'On Demand Email Dialog' )" directly from the console from the same page where the button executes.  I MUST load the page you get from pressing the master_btnEmail (email template selector page), and then interact with this new iframe and only at that point can I simply enter GetEmailClientWindow(....) into the console and have it execute that function. If I already have the Template Selector page pulled up  I can call the function from the console, but it only works in that circumstance.

Unfortunately I also can't seem to get the button to open the Template Selector page and then execute GetMailClientWindow because when the new Template Selector page iFrame loads it seems to stop executing the button logic (since the button is no longer on the page).

I hope this makes sense. Apologies if I have overlooked something here.

Thanks again!

 

Can you post your complete custom object code?

 Advisory Consultant

I tried creating a custom object button using the same code you posted above:

 

<a title="FIND: Assignee Notification for Submission" onclick="javascript&colon;GetEmailClientWindow('EmailClient.aspx?notificationId=386&amp;contentId=274127&amp;subject=FND-2','EmailClient', document.body.offsetHeight - 40, document.body.offsetWidth - 40, 'On Demand Email Dialog' ); return false;" href="javascript&colon;void(0);" target="EmailClient">FIND: Assignee Notification for Submission</a>

 

I also tried swapping out the variables that are relevant to the template I am trying to use (same ones used in my post above):

 

<a title="FIND: Assignee Notification for Submission" onclick="javascript&colon;GetEmailClientWindow('EmailClient.aspx?notificationId=843&amp;contentId=374585&amp;subject=374585','EmailClient', document.body.offsetHeight - 40, document.body.offsetWidth - 40, 'On Demand Email Dialog' ); return false;" href="javascript&colon;void(0);" target="EmailClient">FIND: Assignee Notification for Submission</a>

 

Both of these produce the error: "An unexpected error has occurred in the system. Please try your request again. If problems persist, please contact your system administrator. "

To reiterate: this function GetEmailClientWindow with the parameters set does work in the browser console, but only if the master_btnEmail template choosing iframe has already been loaded (i.e. if I click the email button first).

Thanks again!