2

So I'm making a custom profile center with landing pages and ampscript. All subscriber data populates the form fine. That form when submitted gets posted back to itself where the subscriber data is properly updated. BUT after the form is submitted and the rest of the form loads again it populates the form with OLD data. (ie. If I change my first name from "Jason" to "John" updates occur successfully in ET but after submission the form populates with "Jason" -not "John". If I refresh the page the page shows accurate data with John so I know the processing is successful.

How should I best submit form data and return them to an accurate form. I know I could add alot of code and populate the form manually with POSTED data, but I'd rather pull the data straight from ET.

Is there an ampscript function to refresh subscriber data after making changes?

Code below:

%%[ IF RequestParameter("save") == "save" THEN

/* Collect Form Data */

    SET @email_address = RequestParameter("email")
    SET @firstname = RequestParameter("firstname")

/* UPDATE Attributes */

SET @subkey = @email_address

/* Create the subscriber's object */
    set @subscriber = CreateObject( "Subscriber" )
    SetObjectProperty( @subscriber, "EmailAddress", @subKey )
    SetObjectProperty( @subscriber, "SubscriberKey", @subKey )

    SET @rr2 = CreateObject("RetrieveRequest")
    SetObjectProperty(@rr2,"ObjectType","Subscriber")
    AddObjectArrayItem(@rr2, "Properties", "ID")
    AddObjectArrayItem(@rr2, "Properties", "EmailTypePreference")
    AddObjectArrayItem(@rr2, "Properties", "EmailAddress")
    AddObjectArrayItem(@rr2, "Properties", "SubscriberKey")
    AddObjectArrayItem(@rr2, "Properties", "Status") 

/* SET SUBSCRIBER's ATTRIBUTE */
    SET @att=CreateObject("Attribute")
    SetObjectProperty(@att,"Name","firstname")
    SetObjectProperty(@att,"Value",@firstname)
    AddObjectArrayItem( @subscriber, "Attributes", @att)


/* Update SUBSCRIBER */
   var @createOpts, @saveOpt

/* Create the save option */
    set @saveOpt = CreateObject("SaveOption")
    SetObjectProperty( @saveOpt, "SaveAction", "UpdateAdd" )
    SetObjectProperty( @saveOpt, "PropertyName", "*" )

/* Specify the Update option */
    set @createOpts = CreateObject("CreateOptions")
    AddObjectArrayItem( @createOpts, "SaveOptions", @saveOpt )

/* Update the subscriber */
   set @createStatusCode = InvokeCreate( @subscriber, @createErrDesc, @createErrNo, @createOpts )

/* If we failed to create the subscriber, output the information as the top level error */
IF @createStatusCode != "OK" then
    SET @TheWorks = 'false'
ELSE
    SET @TheWorks = 'true'
ENDIF

ENDIF

var @subscriber_status SET @subkey = [_subscriberkey] SET @save = "FALSE"

/* Create the subscriber's object */ set @subscriber = CreateObject( "Subscriber" ) SetObjectProperty( @subscriber, "EmailAddress", @subKey ) SetObjectProperty( @subscriber, "SubscriberKey", @subKey )

]%%

Your Profile

* = Information is required

My Subscription Profile Email address*: %%emailaddr%% First Name*:

  • Please post some code so we can have a look. – Timothy Oct 28 '14 at 17:19
  • Hope that helps enough. I'm not sure what is causing the code not to display right here. – Jason Oct 28 '14 at 18:23
1

OK, I found the answer. If my Invoke request comes back successful I need to then redirect the page as follows:

Redirect("http://%%microsite_base_url[default]xxxxxx[/default]%%")

where "xxxxxx" is the ID of the current landing page.

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.