Expand my Community achievements bar.

SOLVED

Unable to use the loadlibrary() inside the delivery

Avatar

Level 1

akhileshbh_0-1578927516874.png

Hi,

Anybody can help, why I am unable to use loadlibrary() function inside the delivery. Thank you 

 

kind Regards

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Jon recommends a way which will work for you but Personalisation blocks are not designed to include the Js objects in Deliveries. 

You should use the following method to include the Js.

Amit_Kumar_0-1579083359058.png

This will Add your Js object into your execution context similar to what load library does.

 

in delivery you can use something like: 

<% eval( bigint.data ) ; %>

 

Regards,

Amit

Regards,

Amit

 

View solution in original post

3 Replies

Avatar

Community Advisor

Hi,

 

The loadLibrary() function is not available in deliveries.

Copy the desired js into a personalization block and include that, it's pretty much the same.

 

Thanks,

-Jon

Avatar

Correct answer by
Level 10

Hi,

Jon recommends a way which will work for you but Personalisation blocks are not designed to include the Js objects in Deliveries. 

You should use the following method to include the Js.

Amit_Kumar_0-1579083359058.png

This will Add your Js object into your execution context similar to what load library does.

 

in delivery you can use something like: 

<% eval( bigint.data ) ; %>

 

Regards,

Amit

Regards,

Amit

 

Avatar

Community Advisor

Hello, so I finally figured it out and it works:

  • for one function only which has to be wrapped in () such as
(function b (num) {return num + 4;}) ​
  • also eval it is very slow JS interpreter so if you use it with deliveries where you have a lot of recipients it would take eternity.

In the delivery you can use it by

<% var b = eval (yourscript.data);%>
<%= b(4)%>

 

So I would use personalization blocks as well for the sake of performance and usability.