Salesforce Marketing Cloud (Exact Target), Server side Java script

510 views Asked by At

it is possible to change a subscriber status in the all subscriber list using Server side Javascript?

According the documenttation, the following things should work

Opt-in

<script runat=server>
 Platform.Load("core", "1");

 var myList = List.Init("<id of subscriber list>"); 
 var emailAddress = "<address>"; 
 var subscriberKey = "<subscriberKey>"; 


 var subscriber = {
   "Email Address": emailAddress,
   "Subscriber Key": subscriberKey
 };

// v1:     var status = myList.Subscribers.Update(subscriber,"Active");
// v2:     var status = myList.Subscribers.Update(emailAddress,"Active");

</script>

Opt-out

<script runat=server>
 Platform.Load("core", "1");

 var myList = List.Init("<id of subscriber list>"); 
 var emailAddress = "<address>"; 
 var subscriberKey = "<subscriberKey>"; 

 var subscriber = {
   "Email Address": emailAddress,
   "Subscriber Key": subscriberKey
 };

// v1:     var status = myList.Subscribers.Update(subscriber,"Unsubscribed");
// v2:     var status = myList.Subscribers.Update(emailAddress,"Unsubscribed");
</script>

However if I try to run any of this code (in a sample email in Email studio), I get the following error

Exception of type 'Jint.Native.JsException' was thrown.
 Line: 2061 Char: 20
 throw "Error updating Subscriber on List."
Exception of type 'Jint.Native.JsException' was thrown.

Is there anything I can change to make it work? Is this assumed to be working at all? Best regards Dirk

0

There are 0 answers