I am trying to make a custom preference center, where users can see a list of all publication lists in the business unit they belong to and then choose to subscribe/unsubscribe to such lists.

What I am trying to do is query all publication lists and display them as checkboxes, which I have been able to do without any issues. However, I need to know the Subscribers belonging to each publication list to check if the current user is subscribed to the list (if they are subscribed, the checkbox should appear as "checked" on page load). However, whenever I create certain "AddObjectArrayItem" to the Retrieve Request object, something fails and none of the checkboxes show up (the button on the bottom of the page shows up, but no checkboxes), so I am assuming I must not understand something.

On this page, it says that "Subscribers" is a property of "Publication", so I want to retrieve the Subscriber array from each publication and check if the current user's email/subscriber key match any Subscriber elements. This is causing issues, though.

My code:



     SET @rr = CreateObject("RetrieveRequest")
     AddObjectArrayItem(@rr,"Properties","Subscribers") // SEEMS TO BE PROBLEMATIC LINE
     SET @sub = InvokeRetrieve(@rr)
     FOR @i=1 to RowCount(@sub) DO
         SET @publication = ROW(@sub, @i)
         SET @pubName = Field(@publication, "Name")
         SET @pubID = Field(@publication, "ID")
         SET @pubSubscribers = Field(@publication, "Subscribers") // EVEN IF I REMOVE THIS LINE, IT STILL FAILS
  <input type="checkbox" name="subList%%=v(@pubName)=%%" value="%%=v(@pubID)=%%"> %%=v(@pubName)=%%<br>
     NEXT @i

  <button type="button" onclick="updatePreferences()">Update Preferences</button

  <script type="text/javascript">
      function updatePreferences() {
         const checkboxes = document.querySelectorAll('input[type="checkbox"]');
         // some logic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.