1

I have a DE with three columns with values and two with no values.

enter image description here

I want to send an email to this DE. The email contains a link to a Cloudpage landing page with a form & as customers fill the form I want the respective rows updated i.e. column 4 & 5 with their preferences.

My question is, Is this doable? if yes, then is the below code correct to be used in the Cloud page?

%%[ 

VAR @dataExtensionName, @formSubmitted, @Product, @Duration

SET @dataExtensionName = "testingcloudpage"

SET @formSubmitted = IsNullDefault(RequestParameter("submit"), "")

IF @formSubmitted == "submit" THEN

SET @Product = IsNullDefault(RequestParameter("Product"), "")

SET @Duration = IsNullDefault(RequestParameter("Duration"), "")

ENDIF

]%%

Also, where do I enter this code? Is it in the HTML editor of the submit button of the cloud landing page?

1

There are many ways to achieve your requirement. I feel below approach is easy to start with,

Firstly to identify the subscriber, pass the subkey this to your cloudpage.
To accomplish this you must use the combination of RedirectTo() and CloudPagesURL() methods as below.

Email

SET @subkey = Attribute.GetValue('_subscriberkey')
<a href="%%=RedirectTo(CloudPagesURL(0001,'subkey',@subkey))=%%">Click to update Product details</a>

Cloudpage

  1. You must the the parameters from the Email and form fields both using a common AMPscript method RequestParameter()
  2. And use the upsertData() function to Update your DE with values coming from the form.


%%[
SET @Skey = RequestParameter('subkey')
SET @Product = RequestParameter('Product')
SET @Duration = RequestParameter('Duration')

if RequestParameter("submitted") == true then
    SET @upsertCount = upsertData("testingcloudpage",1,"Subskey", @Skey, "Product", @Product, "Duration", @Duration)
endif
]%%

<!DOCTYPE html>
<html>
   <body>
      %%[ if @upsertCount >= 1 THEN ]%%
         <p>Sucess.</p>
      %%[ if @upsertCount <= 0 THEN ]%%
         <p>Error!.</p>
      %%[ else ]%%
      <h2>Register</h2>
      <form action="%%=RequestParameter('PAGEURL')=%%" method="post">
         <label>Product</label>
         <input type="text" name="Product">
         <label>Duration</label>
         <input type="text" name="Duration">
         <input name="submitted" type="hidden" value="true" />
         <input type="submit" value="Submit">
      </form>
      %%[ endif ]%%
   </body>
</html>

Note: Make sure to update the CLOUDPAGE ID and DE name accordingly.

| improve this answer | |
  • Thanks Vishal. i will give this a go and come back to you if it works. ill be on site in a day. – Rahul G Jun 1 at 20:21
  • 1
    Does the 'Subkey' field is marked as PRIMARY KEY? in your DE! – Vishal Kumar C V Jun 3 at 5:19
  • 1
    oh! Strange!! How come you can have the duplicate values for the PRIMARY KEY field. Can you double check please.... What I understand from your above statement is you are having 2 rows with Subkey = 123 ? – Vishal Kumar C V Jun 4 at 5:30
  • 1
    It would be helpful if you can share screenshot, however what I understand from the above is as you are NOT getting the SubKey, a new row has been created and values are getting stored in a new row... Can you confirm you have placed the code SET @subkey = Attribute.GetValue('_subscriberkey') to get subkey and also try to output this in landing page and check whether it is passed to the cloudpage successfully? – Vishal Kumar C V Jun 8 at 4:32
  • 1
    Hi Vishal, this is now fixed. i had the syntax wrong. thank you for your help mate. – Rahul G Jun 18 at 22:27

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.