I need to add a subscriber to a list particularly the All Subscriber list, for cloudpagesUrl
to work since it returns a broken link if the subscriber is not in the all subscriber list. I already tested and it works if I add the subscriber in the list.
Now the thing is, is there any way for me to add the subscriber to the list using AMPscript/SSJS. I tried some SSJS snippets but it returns me an Error
'Function is not available in sendable content'
I already tried the following
1.)
<script runat="server">
Platform.Load("core","1.1.1");
var subkey = "abc123";
var email = "[email protected]"
var prox = new Script.Util.WSProxy();
var sub = {
SubscriberKey: subkey,
EmailAddress: email,
Lists: [{
ID: '52',
Status: 'Active'
}]
};
var options = {
SaveOptions: [{
PropertyName: "*",
SaveAction: "UpdateAdd"
}]
};
var resp = prox.createItem("Subscriber", sub, options);
Write("Response: " + Stringify(resp));
2.)
<script runat=server>
Platform.Load("core","1");
var myList = List.Init("ListExternalKey");
var status = myList.Subscribers.Add("[email protected]");
Write(status);
</script>
3.)
var @ll_statusMsg
var @listName set @listName = "All Subscriber"
var @rr SET @rr = CreateObject("RetrieveRequest")
SetObjectProperty(@rr, "ObjectType", "List")
AddObjectArrayItem(@rr,"Properties","ListName")
AddObjectArrayItem(@rr,"Properties","ID")
var @sfp SET @sfp = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp, "Property", "ListName")
SetObjectProperty(@sfp, "SimpleOperator", "equals")
AddObjectArrayItem(@sfp, "Value",@listName)
SetObjectProperty(@rr, "Filter", @sfp)
var @Sub SET @Sub = InvokeRetrieve(@rr)
var @ListID Set @ListID = Field(Row(@Sub,1),"ID")
var @ll_sub SET @ll_sub = CreateObject("Subscriber")
SetObjectProperty(@ll_sub, "EmailAddress", "testEmail")
SetObjectProperty(@ll_sub, "SubscriberKey", "AA032912BJK021")
var @subscription set @subscription = CreateObject("SubscriberList")
SetObjectProperty( @subscription, "ID",@ListID)
SetObjectProperty( @subscription, "IDSpecified", "true" )
SetObjectProperty( @subscription, "Status", "Active" )
SetObjectProperty( @subscription, "StatusSpecified", "true" )
AddObjectArrayItem( @ll_sub, "Lists", @subscription )
var @ll_statusCode SET @ll_statusCode = InvokeUpdate(@ll_sub, @ll_statusMsg, @errorCode)
IF @ll_statusCode != "OK" THEN
RaiseError(@ll_statusMsg, 0, @ll_statusCode, @errorCode)
ENDIF
nothing seems to work. any advice will do.
This is how I use my CloudpagesUrl
%%[
var @url set @url = CloudPagesURl(@cloudpageId,'multipleParameters',@valueOfParameters)
var @shortUrl
//Used an api to make @url shorter
]%%
Click %%=RedirectTo(@shortUrl)=%% to view details