I have been working on a profile centre, which can update certain fields like name and email on the all subscriber list. I have been able to do the update part using the code below

SET @sub = CreateObject("Subscriber")
    SetObjectProperty(@sub, "SubscriberKey", @sub_ID)
    SetObjectProperty(@sub,"EmailAddress", @email)
SET @att = CreateObject( "Attribute" )
    SetObjectProperty( @att, "Name", "FirstName" )
    SetObjectProperty( @att, "Value", @fname )
    AddObjectArrayItem( @sub, "Attributes", @att )
SET @att2 = CreateObject( "Attribute" )
    SetObjectProperty( @att2, "Name", "LastName" )
    SetObjectProperty( @att2, "Value", @lname )
AddObjectArrayItem( @sub, "Attributes", @att2 )
SET @sub_statusCode = InvokeUpdate(@sub, @sub_statusMsg, @sub_errorCode)

But I also want to retrieve the values for that purpose I have tried using lookup and API calls but I couldn't fetch custom fields using it. What can be done to solve this issue?

  • Have you tried lookups to the Enterprise Attribute data view? – zuzannamj Feb 1 at 16:55
  • I tried this SET @id = 539719 SET @LURows = LookupRows("_EnterpriseAttribute","_SubscriberID", @id) but it returned an empty rowset – Apoorva Feb 2 at 13:10

You can get values for the custom attributes using the EnterpriseAttribute data view.

The below code will pull the value of a custom field called "PreferredName":

set @id = subscriberid

SET @rows = LookupRows("ent._EnterpriseAttribute","_SubscriberID", @id)

if rowcount(@rows) > 0 then
  for @i = 1 to rowcount(@rows) do

    set @row = row(@rows, @i)
    set @preferredName = field(@row,"PreferredName")

    <br>Row %%=v(@i)=%%, PreferredName: %%=v(@preferredName)=%%

  next @i 

NOTE 1: This data view is for Enterprise 2.0 clients only.

NOTE 2: If you are running your query outside the parent business unit, it has to be used with the ENT. prefix.

  • Thanks! it did work, what i was doing wrong was that I was confusing subscriber id with the subscriber key. They are two different things. SET @subId = Lookup(" _Subscribers ","SubscriberID","SubscriberKey", @id) Used this to get the subscriber id – Apoorva Feb 3 at 6:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.