0

I have a W2C form that need to change the ContactName text field to lookup field that will contain all the contacts in our CRM org and I try to using AMPScript to do it. However, I want to know is that possible to embedded AMPScript into W2C ?

5
  • Just to be sure - Is your page public or are you using an authentication mechanism? You should not expose contact information from your Sales Cloud Org on a public web form. Jun 3, 2020 at 9:51
  • Hi Jonas, thanks for your question.But this web to case form is use to internal page. Jun 3, 2020 at 10:16
  • Sure. Is you Web2Case form built with Sales Cloud or using Marketing Cloud Cloudpages? AMPScript works on Marketing Cloud CloudPages. Jun 3, 2020 at 10:26
  • We try to build a Cloud page in marketing cloud which will available to create case in CRM and the ContactName, Email and Phone will be automatic filled for the link that sent to the user receive it. Is that ok ? Example: I send the cloud page link to contact A then the Contact Name, Email and Phone in this form will be automatic populated by the information of contact A. Jun 3, 2020 at 10:36
  • 1
    I still think you have a potential security issue when somebody gets the email and it lands in the wrong hands, e.g. by forwarding, which cannot be prevented.So I am not a fan, but yes, it can be done. I'll write up an answer. Jun 3, 2020 at 13:41

1 Answer 1

0

Keeping in mind that pre-polutating forms from emails always comes with the risk of someone forwarding their email and someone else seeing their data - this can be done, relatively simply. Assuming you send your email from Marketing Cloud.

You need the function CloudPagesURL() to send encrypted data to your form page. The link in your email that leads to the form will look like this:

<a href="%%=RedirectTo(CloudPagesURL(____))=%%">click me</a>

fill in the CloudPageId of your Cloudpage in the empty space. This will create an encrypted link pointing to your page with encrypted information about the Subscriber the email went to etc. You'll see the parameter "qs" at the end of the link, something like ?qs=iwasdhasfhasfhafhafhuqztqqtw

Make sure your user HAS a subscriberkey, i.e. is on All Subscribers List already, then this will work in the email preview. Otherwise, you need to make a real sendout before you can test.

When accessed through such a link, your Cloudpage now has access to the personalization strings like _subscriberkey and emailaddr that it received in the qs parameter. It automatically decrypts them.

More about personalization strings:

https://help.salesforce.com/articleView?id=mc_es_available_personalization_strings.htm&type=5

You now have two options:

A) make a Lookup on the cloudpage leveraging the _subscriberkey or emailaddr that the page received to find the relevant information about the relevant in a data extension inside marketing cloud:

Assuming you have a DE called nameOfDataExtension and you want the value of the field Lastname, and the SubscriberKey is in the Field "Subscriberkey":

%%[Set @lastname = Lookup("nameOfDataExtension","Lastname","SubscriberKey",_subscriberKey)]%%

You could theoretically do this directly in Sales Cloud (retrieveSalesforceObjects() function), but I would always go with data extensions if possible.

B) If the value of "lastname" is already in your sendout data extension, you can also directly add its value as additional parameter to the CloudpagesURL() functio, which adds it to the encrypted information in qs parameter. Then use that instead of writing a lookup:

Assuming "lastName" is the field which holds the lastname in your sendout data extension, this could be your link in the email:

<a href="%%=RedirectTo(CloudPagesURL(____,"lastname",[lastName]))=%%">click me</a>

It will ONLY work when either previewed against a user with a subscriberkey and using a data extension that has a field "lastname", or when sent to a data extension with this field.

In any case, on your Cloudpage you can now display the value of @lastname in your form input field using:

<input type="text" value="%%=v(@lastname)=%%"> 

see also: https://ampscript.guide/cloudpagesurl/

1
  • Thank you Jonas, I will try to follow your instruction.Really appreciated your help. Jun 4, 2020 at 2:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .