0

I have a use case where I am preparing a cloudpage form with mobile number input field. Upon hitting submit, the mobile number should update in the sales and service cloud under Mobile field. I don't wish to individually update mobile numbers, its a bulk update. this cloudpage will be sent out within in EDM where DE consists of (contact ID18, Account Name, Email, mobile phone (this field can be blank or have a number)) - still only want mobile to be updated, and this can be overwritten by the previous number or fill out a null field.

this is what my code looks so far:

%%[
var @Id, @MobilePhone
set @Id = AttributeValue("_subscriberKey")
  set @MobilePhone = RequestParameter("MobilePhone")
  set @updateRecord = UpdateSingleSalesforceObject(
      "Contact", @Id
      , "MobilePhone", @MobilePhone
     )
]%%
<!DOCTYPE html>
<html>
   <body>
      <h2>Update Your Details</h2>
      <form action="%%=RequestParameter('PAGEURL')=%%" method="post">
         <label>Mobile Phone</label>
         <input type="text" name="MobilePhone" value="%%=v(@MobilePhone)=%%">
         <input name="submitted" type="hidden" value="true" />
         <input type="submit" value="Submit">
      </form>
          %%[ if @updateRecord == 1 then ]%%
         <p>Record Updated</p>
      %%[ elseif @updateRecord == 0 then ]%%
        <p>Update Failed</p>
      %%[ endif ]%%
   </body>
</html>

I have already tested this once and received: 500 - Internal server error.

Please help guys!

Thanks heaps in advance (im a new user of SFMC, so still learning) :)

New contributor
Rad is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
7
  • 1
    can you please include your code as CODE, not as a screenshot? One error that is immediately apparent is a spurious comma after @mobilePhone in your Update call. since updateSalesforceObject is terrible to debug without it, continue with wrapping it in a try catch function as described here: salesforce.stackexchange.com/questions/296953/… – Jonas Lamberty Feb 19 at 16:24
  • @JonasLamberty included the code as code above, and fixing the comma – Rad Feb 19 at 23:53
  • @JonasLamberty so ive put that entire code above between where it says AMPscript code in the code below, what's next steps? <script runat="server" type="text/javascript"> Platform.Load("core","1"); try { </script> <!--%%[ ... AMPscript code ... ]%% --> <script runat="server" type="text/javascript"> } catch (ex) { Variable.SetValue("@error", true) Variable.SetValue("@errorMsg", Stringify(ex)) } </script> – Rad Feb 20 at 0:47
  • after the closing ampscript tag, put %%=v(@errorMsg)=%% which outputs the variable you set in the javascript snippet to contain the error you receive. then put it all on a cloudpage and preview it. you should get an error message displayed instead of just "500". (assuming that the error that triggered the 500 is in the ampscript, which is highly likely). then you can follow the error messages. it's typically some mandatory fields on the object you need to include, or formatting issues. the error message for updateSingleSalesforceObject is usually quite precise. – Jonas Lamberty Feb 20 at 12:04
  • Your _SubscriberKey will be the ContactID, not AccountID. You'd need to get the AccountID first in order to update the Account object. You can lookup the Contact_Salesforce DE or refer to the AccountID field in your sendable Data Extension (if present). If there's a likelihood that the contact landing on the page was created within the last 15 mins and you've not included the Account in your sendable data, do a RetrieveSalesforceObjects() to get the Account ID for the Contact. – Macca Feb 21 at 22:07

Your Answer

Rad is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.