I have a process set-up where people can confirm they have received a message via A Cloudpage. If they open the Cloudpage a field in Salesforce is updated saying they have confirmed. On the object in Salesforce the view_email_url is added as well. The issue is that people who have access to Salesforce can also access the view_email_url and can therefore also confirm the message. This is a problem, because only the contact who originally received the email should be able to confirm this message. I need to find a way that people who access the view_email_url via Salesforce can’t confirm this message.

What I've done so far is append an additional query string to the view_email_url in SF, now my goal is to execute AMPscript on the view_email_url page to prevent people from clicking a link if they have the URL with the additional query string. I can't seem to call the string via queryparameter function. I've tried SSJS as well, but can't find a function to execute on the view_email_url page only

So i've tried this:

SET @CurrentURL = RequestParameter('PAGEURL')

And this:

<script runat="server">
    Platform.Load("core", "1.1.1");
    var currentUrl = Platform.Request.RequestURL;

But these all seem to execute on the MC side.

Any suggestions?


This is how It's currently set up, but this doesn't seem te work

URL for the view as webpage = www.urlgoeshere.com URL that will be displayed in Salesforce = www.urlgoeshere.com?value=SourceSF

SET @SourceSF = '&value=SourceSF'
SET @SFurl = CONCAT(@url, @SourceSF)

SET @Display = TreatAsContent(@SFurl) 

The URL that will display to email recipients are created like:

SET @url = '%%view_email_url%%'

I'm pushing the SF URL using a createsalesforceobject function like so (along with some other values)

SET @result = CreateSalesforceObject("Messages__c",8,"ContactTo__c",@ContId,"URL_received_mail__c",@Display,"Name",@subjectline,
"Delivered_on_E_mail__c",emailaddr,"Status__c",'Send Confirmed',"Timestamp_Delivery__c",
@FinalDate, "Message_Type__c", "Essential Information", "Message__c", @message)

Then on the cloudpage I try to look at the parameter, but it doesn't seem to take into account the source of the View as Webpage (there is a difference between who views the VAWP: Email recipient, or Salesforce user).

SET @value = RequestParameter("Value")

IF @value != "SourceSF" THEN
UpdateSingleSalesforceObject("Messages__c",@BerichtID,"Confirmed__c",'True', "Date_Confirmed__c", @FinalDate)

This is not working and I can't think of a way this would work.

  • a couple things I noticed: 1) @url should be equal view_email_url not '%%view_email_url%%' as that will just be written as a string and not pull in the actual url value. 2) the RequestParameter("Value") is case sensitive I believe so it should be "value" not "Value" as the second will return null as the parameter being set in your code is &value=SourceSF which is lowercase. Mar 2, 2022 at 16:46

1 Answer 1


If I am reading this right, you want it so that if someone is reading the email in a View As Web Page environment that if they click the link to the Cloudpage that it will NOT activate the ampscript you have on that page to 'confirm' in Salesforce.

If so, you will want to use the personalization string of _messagecontext to find if the user is reading the email from a VAWP context.

  IF _messagecontext == "VAWP" THEN
    SET @VAWP= 1
    SET @VAWP = 0

Once you have determined that, I would add a parameter to the end of the URL only in that context to the URL of your cloudpage - needs to be done in your email.

  /* If CloudPagesURL is used */
  <a href="%%=RedirectTo(CloudPagesURL(1234,"Flag",@VAWP))=%%" >link</a>

  /* If raw url */
     SET @url = "https://abc.xyz/mylink"
     SET @finalURL = CONCAT(@url,"?Flag=",@VAWP)
    <a href="%%=RedirectTo(@finalURL)=%%" >link</a>

On the cloudpage, you then have a variable filled if that parameter is true or false and that flag then determines if the AMPscript runs or not.

     SET @flag = RequestParameter("Flag")

     IF @flag != 1 THEN
       /* Your confirm script */
  • Thanks, I believe this is part of the solution. Maybe my question wasn't 100% clear, but I need to make a distinction between people who access the view as webpage via email, and those who access it via Salesforce. What i've done in the email itself, is create two view as webpage url's. One is the 'regular' view as webpage url, which is what people see when the click on 'view online'. To the other i've appended a query string (value=SourceSF), this one is pushed to SF using 'createsalesforceobject). for people who access the link with value=SourceSF the cloudpagesurl shouldn't execute Feb 28, 2022 at 17:17
  • Then you just need to update the flag section to pull the value parameter instead and if it is not equal to SourceSF (instead of 1) then do your confirm script. Slight adjustment to the code should get you there then. Feb 28, 2022 at 21:22
  • Unfortunately, this doesn't seem to work. I've tried this, but I'm still not able to pass the parameter when coming from the VAWP with the value=SourceSF added to the VAWP. The regular email receivers shouldn't receive value=SourceSF in the url, just the ones coming from Salesforce (users). I've edited my question, maybe I'm missing something, but I think this might not be possible Mar 2, 2022 at 16:09
  • @LexJoosten - commented my response on your question with edits Mar 2, 2022 at 16:50

You must log in to answer this question.

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