2

I have a landing page in ET and I am trying to use the smart capture because I want to send a welcome email as soon as the user is added to the data extension.

However, the trigger requires the data extension to have a subscriberkey and email address field and in my case the data for those is the same so I only want to display one input field in the form so someone doesn't have to enter their email twice.

I keep getting error code 2.

This is my code:

%%[[name="FormPost";type="POST"] 
 VAR @de, @de_col, @de_statusCode, @de_statusMsg, @errorCode
Set @SubscriberKey = RequestParameter("SubscriberKey")
IF IsNull(@SubscriberKey) OR Empty(@SubscriberKey) then
Set @SubscriberKey = RequestParameter("EmailAddress")
ENDIF

IF RequestParameter("OptIn") == "true" THEN
SET @OptIn = "true"
ELSE
SET @OptIn = "false"
ENDIF  
SET @de = CreateObject("DataExtensionObject")
SetObjectProperty(@de, "CustomerKey", "OptIn_Welcome")


IF NOT IsNull(@SubscriberKey) THEN
SET @de_col = CreateObject("APIProperty")
SetObjectProperty(@de_col, "Name", "SubscriberKey")
SetObjectProperty(@de_col, "Value", @SubscriberKey)
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF

IF NOT IsNull(RequestParameter("EmailAddress")) THEN
SET @de_col = CreateObject("APIProperty")
SetObjectProperty(@de_col, "Name", "EmailAddress")
SetObjectProperty(@de_col, "Value", RequestParameter("EmailAddress"))
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF

IF NOT IsNull(RequestParameter("OptIn")) THEN
SET @de_col = CreateObject("APIProperty")
SetObjectProperty(@de_col, "Name", "OptIn")
SetObjectProperty(@de_col, "Value", RequestParameter("OptIn"))
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF

IF NOT IsNull(Now()) THEN
SET @de_col = CreateObject("APIProperty")
SetObjectProperty(@de_col, "Name", "DateUpdated")
SetObjectProperty(@de_col, "Value", Now())
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF
SET @de_statusCode = InvokeCreate(@de, @de_statusMsg, @errorCode)

IF @de_statusCode != "OK" THEN
RaiseError(@de_statusMsg, 0, @de_statusCode, @errorCode)
ENDIF
]%%
1
  • Hey gaudy - did i manage to answer your question in full? :) or is there more i can do to help? Jun 15 '17 at 8:21
1

If you only want to display one input field, you should only have one variable, but use that variable in multiple places. E.g.

VAR @subscriberkey
SET @subscriberkey = RequestParameter("YourField")

CreateObject("TriggeredSend")

set email = @SubscriberKey

set subscriberkey = @SubscriberKey

and then run through the rest of the code.

If you need to upsert data into a data extension for tracking purposes, then simply use;

UpsertDate("YourDE",1,"SubscriberKey",@SubscriberKey,"Email",@SubscriberKey)

Hope this helps

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.