How to retrieve the Subscriber Id from a landing page given that we know what the Subscriber Key is?
I tried placing the following ampscript and javascript in a landing page and don't see the subscriber id listed.
AMPSCRIPT:
%%[
SET @subkey = requestParameter("Email Address")
SET @rr2 = CreateObject("RetrieveRequest")
SetObjectProperty(@rr2,"ObjectType","Subscriber")
AddObjectArrayItem(@rr2, "Properties", "ID")
AddObjectArrayItem(@rr2, "Properties", "EmailTypePreference")
AddObjectArrayItem(@rr2, "Properties", "EmailAddress")
AddObjectArrayItem(@rr2, "Properties", "SubscriberKey")
AddObjectArrayItem(@rr2, "Properties", "Status")
SET @sfp2 = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp2,"Property","SubscriberKey")
SetObjectProperty(@sfp2,"SimpleOperator","equals")
AddObjectArrayItem(@sfp2,"Value",@SubKey)
SetObjectProperty(@rr2,"Filter",@sfp2)
SET @atts = InvokeRetrieve(@rr2,@status)
IF RowCount(@atts) > 0 THEN
SET @subAtts = Field(Row(@atts,1),"Attributes")
FOR @c = RowCount(@subAtts) DOWNTO 1 DO
SET @att = Row(@subAtts,@c)
SET @att_name = Field(@att,'Name')
SET @att_val = Field(@att,'Value')
]%%
Att: %%=v(@att_name )=%% %%=v(@att_val)=%%<br/>
%%[
NEXT @c
ENDIF
]%%
JS:
<script runat="server">
Platform.Load("core","1");
try {
var results_DI = Subscriber.Retrieve({Property:"SubscriberKey",SimpleOperator:"equals",Value:"[email protected]"});
var resultsLength_DI = results_DI.length;
Write("<br/>" + resultsLength_DI + "<br/>");
var subObj = Subscriber.Init("[email protected]");
var attributes = subObj.Attributes.Retrieve();
Write("<br/>" + Stringify(attributes) + "<br/>");
var listArray = subObj.Lists.Retrieve();
Write("<br/>" + Stringify(listArray) + "<br/>");
} catch (ex) {
Write("An error has occurred: " + Stringify(ex));
Variable.SetValue("@Result", Stringify(ex)); //sets above ampscript variable
}
</script>