I have a triggered send set up and it works perfectly. Then in the triggered email there is a cloudpagesurl link with all of the data from triggered send DE. Cloud page redirects to a new page called "subscriptions" where a person can edit it's preferences. After a user edits preferences save button should save data but I have an empty DE. It worked fine until I linked Triggered Send DE through cloudpagesurl. Now I'm drawing blanks.

I tried to do and insertdata in the ampscript but page publish with no error but when I try to post data error 500 comes up.

So here is my question. When a user signs up for a newsletter can a trigger send data be posted to two data extensions (1. trigger send DE, 2. preferences DE)?

current code on signup cloud page

%%[ VAR @ts_email, @FirstName, @LastName, @OptIn, @Date, @IPNaslov, @MC_Unit, @ts_subkey, @ts, @ts_def, @ts_extkey, @ts_bunit, @ts_fname, @ts_lname, @ts_opin, @ts_date, @ts_ip, @ts_statusCode, @ts_statusMsg, @errorCode, @createDuplicate

IF RequestParameter("submitted") == "submitted" THEN

SET @ts_email = RequestParameter("EmailAddress")
SET @FirstName = RequestParameter("FirstName")
SET @LastName = RequestParameter("LastName")
SET @OptIn = RequestParameter("OptIn")
SET @Date = SystemDateToLocalDate(Now(1))
SET @IPNaslov = RequestParameter("IPNaslov")
SET @MC_Unit = "Business unit mid"
SET @ts_extkey = "Triggered send ext key"

    "SubscriberKey", RequestParameter("SubscriberKey"),
    "EmailAddress", RequestParameter("EmailAddress"),
    "FirstName", RequestParameter("FirstName"),
    "LastName", RequestParameter("LastName"),
    "OptIn", RequestParameter("OptIn"),
    "IPNaslov", RequestParameter("IPNaslov")
    "Date", @Date

/* Trigger Send Object Creation */
SET @ts = CreateObject("TriggeredSend")
SET @ts_def = CreateObject("TriggeredSendDefinition")
SET @ts_subkey = @ts_email

/* Specify the external key of the TriggerSend */
SetObjectProperty(@ts_def, "CustomerKey", @ts_extkey)
SetObjectProperty(@ts, "TriggeredSendDefinition", @ts_def)

/* Create the Subscriber Object */
SET @ts_sub = CreateObject("Subscriber")
SetObjectProperty(@ts_sub, "EmailAddress", @ts_email) 

/* Set SubscriberKey to EmailAddress */
IF NOT EMPTY(@ts_subkey) THEN
    SetObjectProperty(@ts_sub, "SubscriberKey", @ts_subkey)
    SetObjectProperty(@ts_sub, "SubscriberKey", @ts_email)

/* Fills out the Business unit involved in TriggerSend data extension */
SET @ts_bunit = CreateObject("Attribute")
SetObjectProperty(@ts_bunit, "Name", "ChannelMemberID")
SetObjectProperty(@ts_bunit, "Value", @MC_Unit)
AddObjectArrayItem(@ts_sub, "Attributes", @ts_bunit)

/* Fill out the FirstName field in the TriggerSend data extension */
SET @ts_fname = CreateObject("Attribute")
SetObjectProperty(@ts_fname, "Name", "FirstName")
SetObjectProperty(@ts_fname,"Value", @FirstName)
AddObjectArrayItem(@ts, "Attributes", @ts_fname)

/* Fill out the LastName field in the TriggerSend data extension */
SET @ts_lname = CreateObject("Attribute")
SetObjectProperty(@ts_lname, "Name", "LastName")
SetObjectProperty(@ts_lname,"Value", @LastName)
AddObjectArrayItem(@ts, "Attributes", @ts_lname)

/* Fill out the OptIn field in the TriggerSend data extension */
SET @ts_optin = CreateObject("Attribute")
SetObjectProperty(@ts_optin, "Name", "OptIn")
SetObjectProperty(@ts_optin,"Value", @OptIn)
AddObjectArrayItem(@ts, "Attributes", @ts_optin)

/* Fill out the Date field in the TriggerSend data extension */
SET @ts_date = CreateObject("Attribute")
SetObjectProperty(@ts_date, "Name", "Date")
SetObjectProperty(@ts_date,"Value", @Date)
AddObjectArrayItem(@ts, "Attributes", @ts_date)

/* Fill out the Date field in the TriggerSend data extension */
SET @ts_ip = CreateObject("Attribute")
SetObjectProperty(@ts_ip, "Name", "IPNaslov")
SetObjectProperty(@ts_ip,"Value", @IPNaslov)
AddObjectArrayItem(@ts, "Attributes", @ts_ip)

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

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

IF @ts_statusCode != "OK" THEN
    OUTPUTLINE(CONCAT("Status: ",@TriggerSend_statusMsg," / Code: ",@errorCode))


Tnx in advance

  • Try placing your AMP inside an SSJS Try Catch block to get a more useful error than a 500 Internal Server Error: code4.cloud/articles/…. Also try commenting out your code, slowly introducing sections until you identify the issue that's causing the error. If you're not already doing so, think about developing your code locally with Dropbox... salesforce.stackexchange.com/questions/161622/…. It saves a lot of pain when developing and debugging AMPScript. – Macca Jun 10 '20 at 8:08

1) I don't think you have defined the variable @SubscriberKey correctly. Not sure that you'll get it by RequestParameter("SubscriberKey") from a CloudPagesURL

Try this instead:

Set @subscriberKey = _subscriberkey

This will come through if the page is targeted with CloudPagesURL().

2) This might not be the full extent of the problem. Errors could be in your DE etc., which cannot be debugged here without full transparency. Hence: To work with better errors than "500", isolate your insert and use a try/ catch around it to debug more quickly.

See here, just put your insert into the SSJS wrapper:
How to try catch RetrieveSalesforceObjects in AMPScript

This should print better error messages that actually tell you what the issue is.

  • Jonas, is it needed considering that the other DE called Newsletter_Subscribers (not triggered send) is created in such way that EmailAddress relates to SubscriberKey? (I know it my fault cause I haven't posted the whole code). – Uroš Kenk Jun 10 '20 at 11:53
  • Now I have a different problem. No errors with triggered send, email arrives with cloudpagesurl + attributes in the link. Landing page opens displays all the data from the triggered send DE. This page allows the subscriber to choose additional newsletter topics (checkboxes). When trying to save all of this data into a new DE that will hold subscriptions (insertdata) it passes but no data is inserted into the subscription DE. – Uroš Kenk Jun 11 '20 at 12:53
  • 1
    Hi, you'd be best advised to open a new question for that. – Jonas Lamberty Jun 15 '20 at 13:43

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.