0

I need to update a Salesforce using CloudPages but it is erroring out because of the AMPScript that I have written. Below is my code. When I view the page I get 500 Internal Server error

<!doctype html>
<html>
%%[

var @sflead, @Subskey 
set @sflead = UpdateSingleSalesforceObject('Department_Contact__c','a1V2C000000Gyxxxx','Deactivate__c','true') 

]%%
<head>
</head>
<body>
 HELLO HELLO
</body>
</html>
  • 1
    Does your page display without the AMPScript? Is your page and/or microsite published? – Adam Spriggs Sep 20 '16 at 15:51
  • Yes it works without the AMPScript and it is published also .. – Maneesh Sep 20 '16 at 15:54
  • The same AMPScript works perfectly in an email – Maneesh Sep 20 '16 at 15:55
  • Did you fix your problem with UpdateSingleSalesforceObject on a CloudPage ? I have the same problem, am on touch with Marketing Cloud support, but they can't find a solution in this problem. Thank you for your answer and good luck with that point if you're on same state than me... – Cédric Magno Saraiva Oct 3 '16 at 14:39
  • No I couldn't :( – Maneesh Oct 3 '16 at 14:40
1

Does record exist in Department_Contact__c with an ID of 'a1V2C000000Gyxxxx'? Is 'True' a valid value for the Deactivate__c field?

I would recommend wrapping the AMPScript function in a SSJS try catch statement and then output the error. You should get a more descriptive error than a generic 500 Internal Server error.

Here's an example of a SSJS try catch statement used in conjunction with AMPScript.

<script runat='server'>
  Platform.Load('Core','1.1.1');
  try {
</script>  

%%[
var @sflead, @Subskey 
set @sflead =     UpdateSingleSalesforceObject('Department_Contact__c','a1V2C000000Gyxxxx','Deactivate__c','true') 
]%%

<script runat='server'>
  } 
  catch(e) {
    write(Stringify(e));
  }
</script>  
  • Hi David, am trying to update a custom object (department_contact) .. – Maneesh Sep 20 '16 at 16:59
  • Also, how do I invoke this SSJS from a landing page in Cloudpages? – Maneesh Sep 20 '16 at 17:00
  • The SSJS code can be inline along with your HTML and AMPScript. – David Devoy Sep 20 '16 at 17:02
  • p.s. The UpdateSingleSalesforceObject() function only works if SFMC has been integrated with a Salesforce ORG using the Marketing Cloud Connector. I assume this has already been done. – David Devoy Sep 20 '16 at 17:09
1

I've never been able to get the SSJS try catch statement to work for me in CloudPages. I just get the 500 Server Error.

Here's a solution to debug:

  1. Create a new Paste HTML email
  2. Paste the HTML from the CloudPage in the text area and click Save
  3. Click on the Text tab and remove the AMPscript code block (to prevent the code from executing twice when previewing)
  4. Click Send Preview
  5. Select All Subscribers
  6. Select any Subscriber
  7. Click Generate Preview

The AMPscript error will be displayed on the page.

  • The AMPScript is working perfectly in email but not in Cloudpages .. – Maneesh Sep 20 '16 at 22:11
  • @ManeeshGupta, that's bizarre. Are you using the same Business Unit? Are you waiting for a sufficient time for the change to propagate across the CDN after publishing? Something else I would try is to drop your AMPscript into a ContentArea then include it in the CloudPage using the ContentArea() AMPscript function, so any changes you make to the ContentArea will be immediately reflected on your CloudPage, which is a lot quicker than waiting for the updated page to propagate. – Eliot Harper Sep 20 '16 at 22:15

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.