0

I am creating Subscribers using AMPScript in my Landing Page like this:

SetObjectProperty(@sub, "SubscriberKey", @SubscriberKey)
SetObjectProperty(@sub, "EmailAddress", @Email)
SetObjectProperty(@sub, "Status", @SubscriberStatus)
SET @statusCode = InvokeCreate(@sub, @statusMsg, @errorCode)

I know I need to create a new object like this

SET @attribute=CreateObject(Attribute)
SetObjectProperty(@attribute,'Name','First Name')
SetObjectProperty(@attribute,'Value','John')

But I don't know how to connect the two, there is a AddObjectArrayItem but I'm not sure where to add it.

1 Answer 1

1

You connect the two by using the AddObjectArrayItem() AMPScript function. The final code would look like the following. Pay special attention to the second to the last line of code.

SET @attribute=CreateObject(Attribute)
SetObjectProperty(@attribute,'Name','First Name')
SetObjectProperty(@attribute,'Value','John')

SET @sub = CreateObject("Subscriber")
SetObjectProperty(@sub, "SubscriberKey", @SubscriberKey)
SetObjectProperty(@sub, "EmailAddress", @Email)
SetObjectProperty(@sub, "Status", @SubscriberStatus)
AddObjectArrayItem(@sub, "Attributes", @attribute)
SET @statusCode = InvokeCreate(@sub, @statusMsg, @errorCode)
1
  • The first line of your code is missing quotes around the Attribute parameter. It should look like this: SET @attribute=CreateObject("Attribute")
    – Hroosha
    Mar 16, 2023 at 3:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .