Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

how to call javascript code filename in email delivery template

Avatar

Level 1

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
in the advanced javascript code use the loadlibrary to load the library and then you can call the function.

View solution in original post

6 Replies

Avatar

Community Advisor

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,

Avatar

Level 1

Thanks Manoj..

 

in the javascript function i am trying to return the word...
in the delivery template i have called the function,

 

do i need to provide the loadlibrary inside the delivery template?

Avatar

Community Advisor
Yes, for that you can add all your coding the advanced tab of the delivery activity and then once you have the word then store it in a delivery variables and finally call that variable in the HTML

Avatar

Correct answer by
Community Advisor
in the advanced javascript code use the loadlibrary to load the library and then you can call the function.

Avatar

Community Advisor

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