# Retrieve and update attribute data from a list

I am building a cloudpage to replace the standard subscription center. I want handle the email list subscriptions in there through checkboxes.

I am already stuck at visualizing the subscription lists.

The code I have so far is the following:

%%[
var myList = List.Init('Promotions')

var subs = myList.Subscribers.Retrieve({Property:"Email Address", SimpleOperator:"equals", Value:"testSFMC@gmail.com"})
%%]
%%=v(@subs)=%%


When trying to generate the cloudpage, I get an internal server error. This indicates that something is wrong with AMPscript but I don't know what.

Edit: New code

<script type="javascript" runat="server">
var promotions = List.Init('Promotions');

var subscriber = promotions.Subscribers.Retrieve({Property:"Email Address",SimpleOperator:"equals", Value:"matthias.claes@forward.eu"});

Variable.SetValue("subscriber", subscriber);
</script>
%%[
set @rowCount = rowcount(@subscriber)

var @status
var @subscriberKey
set @status = "empty1"
set @subscriberKey = "empty2"

if @rowCount > 0 then
set @row = row(@subscriber,1) /* get row #1 */
set @status = field(@row,"Status")
set @subscriberKey = field(@row,"Subscriber Key")
endif
]%%

%%=v(@status)=%% <br>
%%=v(@subscriberKey)=%% <br>


this is not AMPScript, you are writing Server Sided JavaScript. If you WERE using AMPScript, the closing tag should look like this though: ]%%

When working with lists, refer to the documentation for SSJS. In general, working with lists is a lot harder than working with data extensions in this regard. probably not an option, just wanted to note it.

With that said, the following should be wrapping your code - Start by loading the Core Library, otherwise the list.Subscribers method does not work: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/ssjs_listFunctions.htm

<script type="javascript" runat="server">
</script>


If you want to display the "@subs" AMPScript variable, you can set the AMPSCript variable from Javascript using Variable.SetValue():

Variable.SetValue("subs",subs);


in sum, this would be my starting point (untested).

<script type="javascript" runat="server">