how to call javascript code filename in email delivery template | Community
Skip to main content
August 26, 2020
Solved

how to call javascript code filename in email delivery template

  • August 26, 2020
  • 2 replies
  • 3149 views

Hi Friends,i have a question and it would be helpful if i get the solution.

 

Created a javascript code with function abc() and the filename as "xyz.js".

In Campaign email delivery template i have used the below code to call the function and the javascript filename:

 

<script src="xyz.js"></script>

<%=abc()%>

 

But i am getting an error like abc is not defined.

do i need to load the file to pick the particular filename?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Manoj_Kumar
in the advanced javascript code use the loadlibrary to load the library and then you can call the function.

2 replies

Manoj_Kumar
Community Advisor
Community Advisor
August 26, 2020

Hello @ashajosh 

 

Can you share more details on what you are trying to do with the javascript in the delivery template.

 

Calling javascript with <script> tags is not the right way in adobe campaign. You can use loadLibrary('NAMESPACE:JS_FILE_NAME')

 

Thanks,

Manoj  | https://themartech.pro
Manoj_Kumar
Community Advisor
Manoj_KumarCommunity AdvisorAccepted solution
Community Advisor
August 26, 2020
in the advanced javascript code use the loadlibrary to load the library and then you can call the function.
Manoj  | https://themartech.pro
Jonathon_wodnicki
Community Advisor
Community Advisor
September 3, 2020

Hi,

 

The <script/> tag is rendered client-side, and immediately stripped by every email client since its invention.

If you're trying to use a server-side include, those are unavailable to the MTA process.

You can include JS with personalization blocks (I usually do this), or by eval()'ing response from delivery query (for cross-purpose JS).

 

Thanks,

-Jon