Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

JavaScript with SQL on an Adobe Campaign SL (in a delivery)

Avatar

Level 2

Hi, I need your help.

I am trying to run an SQL statement using Javascript in the SL section of a delivery.

The code runs fine when doing a Preview, but then breaks when Proofing.

These are the errors I get when trying to send the Proof: 

1454730_pastedImage_3.png

1454731_pastedImage_4.png

These are the errors I see when visiting the proof details:

1454736_pastedImage_5.png

1454737_pastedImage_6.png

This is the JS code I use in the SL, you can see from the screenshot that the preview works and pulls data from the SQL statement.

screenshot.png

Does this mean that I cannot use SQL in the Javascript on my Subject Line or body content?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi Alex,

Yes, I got it now. Thanks for clarifying.

But, as per my understanding, we can't use complex JavaScripts in the Subject Line.

Because all variables and methods of JS are not defined for Subject Line.

I tried to run some JS in the subject line and tried to fetch the data using queryDef, but got the below error :

js Error while executing the method 'ExecuteQuery' of service 'xtk:queryDef'.

And when I tried the same JS in the JavaScript Activity, it was running fine.

It means that ExecuteQuery method is not available for Subject Line, That's why I conclude that we can't use complex JS in the Subject Line. I hope it helps.

View solution in original post

5 Replies

Avatar

Employee Advisor

Hi,

Can you please explain what exactly is your requirement to run SQL in the Subject Line ?

Because if you just want to Put Recipient's FirstName and LastName in the Subject Line, then just use the below syntax :

<%= recipient.firstName %>

<%= recipient.lastName%>

1456123_pastedImage_0.png

Now if you will preview the delivery, it won't be showing the actual first name and last name of recipient, it will just show the syntax you have written there in the Subject Line.

But, if you will actually send the Delivery, it will take the First and Last Name of the recipient. You can verify that by sending the delivery to yourself first.

Regards,

Kapil Sharma

Avatar

Level 2

Hi Kapil and thanks for your reply.

I am not trying to display first name and last name on my Subject Line.

I am trying to figure out if I can run queries in the subject line to record which user received which dynamic content in Adobe Campaign.

Thus, I need to be able to run a query that saves data after my JS selects an SL to be displayed e.g. X user got Y SL.

I hope this is more clear now.

Alex

Avatar

Correct answer by
Employee Advisor

Hi Alex,

Yes, I got it now. Thanks for clarifying.

But, as per my understanding, we can't use complex JavaScripts in the Subject Line.

Because all variables and methods of JS are not defined for Subject Line.

I tried to run some JS in the subject line and tried to fetch the data using queryDef, but got the below error :

js Error while executing the method 'ExecuteQuery' of service 'xtk:queryDef'.

And when I tried the same JS in the JavaScript Activity, it was running fine.

It means that ExecuteQuery method is not available for Subject Line, That's why I conclude that we can't use complex JS in the Subject Line. I hope it helps.

Avatar

Level 2

yeah, it seems so. thanks for checking

that is an issue for us.

thus, I guess any data saving needs to happen after the delivery has gone out, maybe on a Javascript activity to save these data.

Avatar

Employee Advisor

Yes, you can store the dynamic content as per the individual recipients with the help of the JavaScript.

This surely can be achieved by the JavaScript.