1

I have some ampscript that works fine when in its own cloudpage:

%%[
VAR @ts, @tsDef, @ts_sub, @ts_statusCode, @errorCode, @id
SET @id = REQUESTPARAMETER('id')

SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")

SetObjectProperty(@tsDef, "CustomerKey", "PostDOILoyaltyNUEN")
SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)

SET @ts_sub = CreateObject("Subscriber")
SetObjectProperty(@ts_sub, "SubscriberKey", @id)

AddObjectArrayItem(@ts, "Subscribers", @ts_sub)

SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)

]%%

But when I add it to a more complex cloudpage that contains other logic, it doesn't work.

%%[
VAR @sfid, @lan, @exp, @result, @today, @valid, @len, @ts, @tsDef, @ts_sub, @ts_statusCode, @errorCode, @id, @ts_statusMsg
SET @sfid = REQUESTPARAMETER('sk')
SET @lan = REQUESTPARAMETER('ln')
SET @id = REQUESTPARAMETER('id')
SET @exp = REQUESTPARAMETER('expiry')
SET @today = FormatDate(Now(), 'yyyy-MM-dd')

SET @len = Length(@sfid)
IF EMPTY(@sfid) THEN
 redirect(CloudPagesURL(890))
ELSEIF @len != '18' THEN
 redirect(CloudPagesURL(907))
ELSEIF EMPTY(@lan) THEN
    redirect(CloudPagesURL(908)) /*redirects  to error page*/
ENDIF

IF @exp > @today THEN
SET @valid = TRUE
SET @result = UpdateSingleSalesforceObject('MAG_Subscription__c', @sfid, 'MAG_Status__c', 'Verified')
SET @result = UpdateSingleSalesforceObject('MAG_Subscription__c', @sfid, 'MAG_VerifiedDate__c', @today)
SET @result = UpdateSingleSalesforceObject('MAG_Subscription__c', @sfid, 'Welcome_Email__c', 'TRUE')
ELSE
SET @valid = FALSE
ENDIF

SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")

SetObjectProperty(@tsDef, "CustomerKey", "PostDOILoyaltyNUEN")
SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)

SET @ts_sub = CreateObject("Subscriber")
SetObjectProperty(@ts_sub, "SubscriberKey", @id)

AddObjectArrayItem(@ts, "Subscribers", @ts_sub)

SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)

]%%

It doesn't make sense why it wouldn't work. Any help is very much appreciated.

  • Can you please elaborate on 'It doesn't work'. Is there an error? nothing sends? etc? – Gortonington Jan 22 at 14:26
  • my bad. was linked to the wrong cloudpage. d'oh – neo2049 Jan 22 at 14:41
0

email was linked to the wrong cloudpage. d'oh

  • 1
    This answer is in the Low Quality Posts review queue. I recommend you either add more detail here (e.g. "Make certain you check Some > Config > Path") or just delete both question and answer. – Adrian Larson Jan 22 at 15: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.