4

I'm trying to use this code and I'm facing this error:

<script runat="server">
Platform.Load("core","1");
  var subscriber = {"Status": "Active"};
  var key = '00003';
  try {
  var sub = Subscriber.Init(key);
  } catch (e)
  {
  Write("<br> Fail: " + Stringify(e));
  }

</script>

Error:

Fail: {
  "message":"CreateObject Function is not valid in content. This function is only allowed in non sendable content.\r\n Function: CreateObject(\"Subscriber\")",
  "description":"ExactTarget.OMM.FunctionExecutionException: CreateObject Function is not valid in content. This function is only allowed in non sendable content.\r\n Function: CreateObject(\"Subscriber\")\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from Jint\r\n\r\n"
}

Also this code:

<script runat="server">
  Platform.Load("core","1.1.1");
    
try {
  </script>
%%[
SET @ll_sub = CreateObject("Subscriber")
SetObjectProperty(@ll_sub, "EmailAddress", "[email protected]")
SetObjectProperty(@ll_sub, "SubscriberKey", "00003")

]%%

<script runat="server">
  Platform.Load("core","1.1.1");
    
  } catch (e) {
  Write("<br> Fail: " + Stringify(e));
  }
  </script> 

Aaand also this one:

<script runat="server">
Platform.Load("core","1.1.5");
try {
var prox = new Script.Util.WSProxy();
var props = ['Id', 'ListName', 'Description'];
var filter = {
    Property: 'ListClassification', 
    SimpleOperator: 'equals',
    Value: 'PublicationList'
};

var result = prox.retrieve('List', props, filter);

  Write(result);
  } catch (e)
  {
  Write("<br> Fail: " + Stringify(e));
  }
  
</script>

I'm getting the same error.

Error:

Fail: {"message":"Exception has been thrown by the target of an invocation.","description":"System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. - from mscorlib --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.FunctionExecutionException: WSProxy object is not valid in sendable content. This function is only allowed in non-sendable content.\r\n Object: Script.Util.WSProxy()\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n"}

Maybe a new release has impacted the use of those functions?

5
  • That error is usually only given when placed inside an email or otherwise 'sendable' context. Just due to that, I am going to validate again that this is existing inside of a CloudPage and not an email, right? Apr 14, 2021 at 18:11
  • Yes, inside a CloudPage. I use CloudPage for debugging purposes. In a SSJS Activity in Automation Studio those codes are working. Apr 14, 2021 at 18:28
  • I think then you will need to push a support case in to SFMC support as that sounds like a platform issue and not a code/user issue since that error should never technically be thrown in a non-sendable context. Apr 14, 2021 at 18:30
  • 1
    Thank you so much! Apr 14, 2021 at 18:31
  • 1
    @Gortonington I've made a test with WSProxy and getting the same error. I'm working with the Support trying to explain the error. What i'm worried that i've got this error in three different instances (Three different MIDs) Apr 16, 2021 at 0:26

1 Answer 1

8

This behavior started occurring in a recent Marketing Cloud release. It occurs when you preview the CloudPage before publishing. It appears that Salesforce has changed the way that CloudPages are interpreted (and now use the same process as email previews). If you publish the page, then this error should not occur and your code will be interpreted correctly.

1
  • do we have any alternate way? Some clients don't allow the publishing of cloud pages, where could we possibly test our code. Does this imply, ssjs activity in Automation Studio is the only option left? May 3, 2021 at 8:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .