0

I am building a custom preference center in SFMC with SSJS that will pass the subscriber context into the landing page via the microSiteUrl() from an email. I am building out and testing JUST the landing page portion. I am having an issue publishing the page - it will error out when I have the following code active. If I comment the code out, the page will publish. I NEED the information in order to run the logUnsubscribeEvent. I was given the following as a way to write my code. It still doesn't work. The page will not publish - I just get the spinner. What am I missing. This is my code:

<!-- AMPScipt to retrieve subscriber context from microSiteUrl() -->
%%[

     SET @subscriberKey = _subscriberkey
     SET @jobID = jobid 
     SET @batchID = _JobSubscriberBatchID 
]%% 
<script runat="server">

    Platform.Load("core","1");

    /* declare variables */

    /*retrieve values set in AMPscript */
    var subKey = Variable.GetValue("@subscriberKey");
    var batch = Variable.GetValue("@batchID");
    var job = Attribute.getValue('@jobID');

</script>

it's not showing up in my code above .. but SSJS IS wrapped in opening and closing script runat="server" tags

2

No need to do the AMPscript block first.

The SSJS has the same context as the AMPscript block. You can just retrieve them directly with Attribute.GetValue():

<script runat="server">

    Platform.Load("core","1");
    var subKey = Attribute.GetValue("_subscriberkey");
    var batch = Attribute.GetValue("_JobSubscriberBatchID");
    var job = Attribute.GetValue('jobid');

</script>
  • I've tried this and the page will not publish. It will just continue to get the spinner. If I comment out the section with Attribute.GetValue() the page publishes fine. Any other thoughts??? – Paulette Vallad Apr 20 '18 at 13:42
  • -tried it again and it worked. I could publish!!!! Thank you so much @Adam – Paulette Vallad Apr 20 '18 at 14:03

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.