2

I could be able to create a subscriber to the list with the below code .But i can't be able to update the subscriber (with the InvokeUpdate function) if the email already exist??

SET @subscriber = CreateObject("Subscriber") SetObjectProperty(@subscriber,"EmailAddress",@var_emailaddress)

SetObjectProperty(@subscriber,"SubscriberKey",@var_emailaddress)

SET @attribute=CreateObject("Attribute")
SetObjectProperty(@attribute,"Name","FirstName")
SetObjectProperty(@attribute,"Value",@var_firstname)
AddObjectArrayItem(@subscriber, "Attributes", @attribute) 

SET @attribute=CreateObject("Attribute")
SetObjectProperty(@attribute,"Name","LastName")
SetObjectProperty(@attribute,"Value",@var_lastname)
AddObjectArrayItem(@subscriber, "Attributes", @attribute)
Set @options = CreateObject("UpdateOptions") 
Set @save = CreateObject("SaveOption") 
SetObjectProperty(@save,"SaveAction","UpdateAdd") SetObjectProperty(@save,"PropertyName","Attribute") AddObjectArrayItem(@options,"SaveOptions", @save)

SET @list = CreateObject("SubscriberList")
SetObjectProperty(@list, "Status", "Active")
 SetObjectProperty(@list, "ID", "VALID EXISTING LIST ID")
     AddObjectArrayItem(@subscriber, "Lists", @list)

SET @statusCode = InvokeUpdate(@subscriber, @statusMsg, @errorCode, @options)

IF @statusCode == "OK" THEN Redirect('http:')

ELSEIF @statusCode != "OK" THEN

SET @statusCode = InvokeCreate(@subscriber, @statusMsg, @errorCode, @options)

IF @statusCode == "OK" THEN

Redirect('http:')

ELSE Redirect('http:')

ENDIF

ELSE Redirect('http:') ENDIF

THIS WHOLE CODE NOW CAN UPDATE PLUS CREATE THE SUBSCRIBER LIST!!

  • Are you setting the SubscriberKey Attribute when updating? – Alex Finger Aug 21 '14 at 13:38
  • not in the code but the subscriber key is being filled with email address in the exacttarget subscriber lists. – Jack85 Aug 21 '14 at 14:08
1

1) Cannot Create a List and Update a Subscriber in the same call. Can only add a Subscriber to a List that is already created.

Change List code to:

SET @list = CreateObject("SubscriberList")
SetObjectProperty(@list, "Status", "Active")
SetObjectProperty(@list, "ID", "VALID EXISTING LIST ID")
AddObjectArrayItem(@subscriber, "Lists", @list)

2) It would seem that creating a SubscriberList via the InvokeCreate function is not possible (or highly difficult). Please someone correct me if I am wrong. I only get Errors like: ListNotFound and Object reference not set to an instance of an object.

It sounds like you may not be able to create a SubscriberList on the fly. I would reach out to ExactTarget for additional support if this is a must.

  • I changed the list code .. nice.. as you said ...can't create and update at the same time ...if i use InvokeUpdate function i can only update and if i use InvokeCreate function then i can only create..now i have to think how to haev one code page and do both – Jack85 Aug 22 '14 at 10:27
  • WITH YOUR POINTERS I CAN BE ABLE TO FINISH THE TASK..THX – Jack85 Aug 22 '14 at 13:08
0

Set the SubscriberKey with the email address in the AMPScript.

  • am not using any API or sth..It is just a form LandingPage with script.. – Jack85 Aug 21 '14 at 14:18
  • 1
    Edited. Set the SubscriberKey in addition to the Email Address (with the Email Address) – Alex Finger Aug 21 '14 at 14:23
  • 1
    Is this in an email or a landing page? Do you get an error? – Alex Finger Aug 21 '14 at 17:44
  • 1
    Please remove the line: IF @statusCode == "OK" THEN Redirect('http:') ELSE Redirect('http:') And add the line: v(@statusMsg) – Alex Finger Aug 22 '14 at 9:01
  • 1
    Right, that means the subscriber already exists in the All Subscribers master list. You need to use InvokeUpdate if that is the case. – Alex Finger Aug 22 '14 at 10:31

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.