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) :)
@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/…%%=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.