I am attempting to call an external microsite page (content type is text/javascript) in a Script activity. This external javascript contains functions to be used in multiple SSJS scripts.

edit: I also tried using a Content Area and have updated the code below.

<script type="text/javascript" src="[micrositepage]"></script>
<script type="text/javaScript" runat="server">

    Platform.Load("core", "1");
    var globalVarsFunctions = ContentAreaObj.Init("GlobalVarsFunctions_732226");


    // Retrieve rows and sort by priority. 
    var DE_ContentDetails_Rows = DE_ContentDetails.Rows.Retrieve();

I've removed the page in the source above, but the original contains the variable for "DE_ContentDetails".

The error I'm receiving indicates the external JS code is not being referenced as it cannot find the DE_ContentDetails object.

Unable to generate preview A scripting error has occurred.
Object expected: Retrieve
Line: 11 Char: 1 var DE_ContentDetails_Rows = DE_ContentDetails.Rows.Retrieve()

  • I've also tried including runat="server" in the external JS call with the same issue.
    – Daniel
    Aug 31 '16 at 13:53
  • whats runat="server" with javascript... runat server does not exists in Visualforce Aug 31 '16 at 14:25
  • The question is regarding SSJS for a Script Activity within the Salesforce Marketing Cloud.
    – Daniel
    Aug 31 '16 at 16:29
  • is this external site inside SFMC or on a 3rd party host? Aug 31 '16 at 16:51
  • It is a micro site landing page hosted within the salesforce marketing cloud. The landing page is set up with a conent type = text/javascript.
    – Daniel
    Aug 31 '16 at 17:06

If you want to include a Content Area in your SSJS code, you will first need to initialise it using the ContentAreaObj.Init() function as documented here.

You will then be able to use the ContentArea() or ContentAreaByName() SSJS functions.

  • Implementing this resulted in the same error. I wonder if I misinterpreted anything? I've updated the code in the original question to reflect the content area init and call.
    – Daniel
    Aug 31 '16 at 23:39
  • I've tried using the documented Content Area SSJS functions and can't get them to work. It's annoying when you follow documented code examples and they don't work. Not sure what the solution would be here... Sep 1 '16 at 3:00

If you want to get the Content Area using SSJS code then you will need to use SSJS Utilities Content Area functions.

<script type="text/javaScript" runat="server">
Platform.Load("core", "1");
    var myContent = ContentArea(176240);
  • Unfortunately, this did not work and resulted in the same error. The ContentArea contains SSJS code that needs to be executed and it doesn't appear to be doing that using your suggested code.
    – Daniel
    Sep 2 '16 at 18:53
  • Not sure, Maybe some problem in your contentarea sssjs code. update your content area ssjs code here
    – Palash Rai
    Sep 7 '16 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.